在 M1 芯片 Mac 上使用 Homebrew

Homebrew 官方已经release 3.0的版本支持 M1 芯片啦 !!!

命令就直接是官网的readme,亲测有效

export HOMEBREW_BREW_GIT_REMOTE="..."  # put your Git mirror of Homebrew/brew here
export HOMEBREW_CORE_GIT_REMOTE="..."  # put your Git mirror of Homebrew/homebrew-core here
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

如果在内地,且也只想更新用中科大的源,直接cp我下面的脚本即可!

export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

如果想卸载之前按照教程安装的非原生M1 homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"

确认是否卸载干净 : 最后可以确认下 /opt/Homebrew目录 和 /usr/local/Homebrew 是否还在

/opt/Homebrew应该是直接按照教程自己make出来的目录,/usr/local/Homebrew 应该是3.0版本直接借助官方命令安装homebrew后存储的位置。

安装 ARM 版 Homebrew

ARMHomebrew需要安装在/opt/homebrew路径下,早期的时候需要手动创建目录执行命令,目前使用最新脚本不需要手动操作。

直接执行:

/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"

然后还需设置环境变量,具体操作步骤如下,一定要仔细阅读。

PS: 终端类型根据执行命令

echo $SHELL

 

显示的结果:

  • /bin/bash => bash => .bash_profile
  • /bin/zsh => zsh => .zprofile

如果遇到环境变量无效问题,建议回过头来查看终端类型,再做正确的设置。

macOS Catalina(10.15.x) 版开始,Mac使用zsh作为默认Shell,使用.zprofile,所以对应命令:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile 
eval "$(/opt/homebrew/bin/brew shellenv)"

如果是macOS Mojave 及更低版本,并且没有自己配置过zsh,使用.bash_profile

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile 
eval "$(/opt/homebrew/bin/brew shellenv)"

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注