天天看點

Mac M1安裝Homebrew記錄

1、異常

Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
  https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
  brew bundle dump      

由于我是從老的MacBook Pro遷移到M1的,是以老的Homebrew版本在M1 ARM上已經不可用了。

2、安裝Homebrew

2.1、執行安裝指令

/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"      
國内環境可用

安裝需要電腦密碼:

==> Checking for `sudo` access (which may request your password).
Password:      

輸入會繼續執行下載下傳安裝。

安裝完成會有提示:

Mac M1安裝Homebrew記錄

可以執行指令​

​brew help​

​驗證是否安裝完成。

2.2、配置環境

如上圖所示,需要配置一下Homebrew環境

2.2.1、終端類型

先檢視自己的終端類型

執行指令:

echo $SHELL      
Mac M1安裝Homebrew記錄

執行結果:

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

2.2.2、配置環境

在你的.bash_profile檔案或.zprofile檔案中添加安裝完成所提示的環境配置。

在訪達的個人空間中,快捷鍵​

​command+shift+.​

​可以把隐藏檔案顯示出來。

我的按照提示即添加如下:

cho 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/yechao/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"      

然後執行指令重新整理環境即可

source ~/.bash_profile       

or

source ~/.zprofile      

3、相關資料

  • ​​https://docs.brew.sh/Installation​​
  • ​​https://brew.idayer.com/guide/m1/​​
  • ​​https://stackoverflow.com/questions/66666134/how-to-install-homebrew-on-m1-mac​​

繼續閱讀