解决M1芯片的Homebrew安装问题--For M1使用者

在这里插入图片描述
homebrew是Mac上非常实用的软件管理工具,但是Mac的M1从x86架构转换成arm架构,原来的homebrew对于新的机子不适用,我们可以自己安装配置环境。官方安装连接
在MacBook Pro m1上配置安装,需要安装到/opt/homebrew目录下,x86架构默认安装到/usr/local/homebrew 。(安装步骤中终端默认使用的是zsh,大家应该熟悉Linux和vim吧~)

  1. 首先是在opt目录下新建一个homebrew目录,并且给homebrew设置权限,之后会使用到。
sudo mkdir -p /opt/homebrew
sudo chown -R $(whoami) /opt/homebrew
  1. 进入到opt目录下,使用下面的命令从官网下载homebrew并解压。
cd /opt
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

如图是下载完的结果:
在这里插入图片描述
3. 除此之外需要配置brew的环境。使用vim编辑bash_profile文件,将export PATH=$PATH:/opt/homebrew/bin;(注意分号)添加到bash_profile文件并保存退出,使用下面的source命令刷新文件,使得命令生效。

vim ~/.bash_profile

source ~/.bash_profile

如下如所示:
在这里插入图片描述
输入brew测试安装情况:
在这里插入图片描述

:如果终端退出,再次输入brew可能会提示没有这个命令,要么使用source ~/.bash_profile重新刷新一次,或者在zshrc文件配置,因为mac终端用的是zsh。

vim ~/.zshrc
#在文件末尾加入如下命令
source ~/.bash_profile
  1. 除此之外,我们是在homebrew官网下载的镜像,有时候可能会很慢,可以使用国内的源镜像,速度更快一些,使用如下命令更新源。
cd "$(brew --repo)"
git clone https://mirrors.ustc.edu.cn/brew.git
 
 
cd "$(brew --repo)/Library/Taps/homebrew"
 
git clone https://mirrors.ustc.edu.cn/homebrew-core.git
 
git clone https://mirrors.ustc.edu.cn/homebrew-cask.git
 
brew update #brew的更新命令,可以使用brew查看这个命令
镜像地址:
HomeBrew 官方镜像:
brew: https://github.com/Homebrew/brew
core: https://github.com/Homebrew/homebrew-core
cask: https://github.com/Homebrew/homebrew-cask
清华大学镜像:
brew: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
core: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
cask: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
中科大镜像:
brew: https://mirrors.ustc.edu.cn/brew.git
core: https://mirrors.ustc.edu.cn/homebrew-core.git
cask: https://mirrors.ustc.edu.cn/homebrew-cask.git
  1. 最后可以使用brew愉快的安装软件了,good luck!
brew install 软件名

本人能力有限,难免出错,欢迎大家指正,一起学习,一起进步!一起加油!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值