Arm版本
cd /opt # 切換到 /opt 目錄
mkdir homebrew # 建立 homebrew 目錄
sudo chown -R $(whoami) /opt/homebrew # 修改目錄所屬使用者
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
cd /homebrew/bin
brew --version
注意:由於arm版的homebrew可能有些軟體不太相容,所以需要安裝intel版的x86進行相容,為了兩個不相沖突,需要重新命名homebrew。
安裝intel版:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
執行 vim ~/.bash_profile
# x86
$ export PATH="/usr/local/Homebrew/bin:$PATH"
$ alias xbrew='arch -x86_64 /usr/local/Homebrew/bin/brew'
# arm
$ export PATH="/opt/homebrew/bin:$PATH"
$ alias brew='/opt/homebrew/bin/brew'
執行 source ~/.bash_profile
說明:如果你需要用arm版的安裝則 brew install xxx ,如果需要intel x86安裝則 xbrew install xxx
最終結果可以看到:
xiaowen@xiaowendeMBP / % brew config
HOMEBREW_VERSION: >=2.5.0 (shallow or no git repository)
ORIGIN: (none)
HEAD: (none)
Last commit: never
Core tap: N/A
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_BOTTLE_DOMAIN: https://mirrors.ustc.edu.cn/homebrew-bottles
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 12.0 build 1200
Git: 2.24.3 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.0.1-arm64
CLT: N/A
Xcode: 12.4
Rosetta 2: false
xiaowen@xiaowendeMBP / % xbrew config
HOMEBREW_VERSION: 2.7.7-40-g24bbfff-dirty
ORIGIN: https://mirrors.ustc.edu.cn/brew.git
HEAD: 24bbfffc61f905a212f5fcb29e44199520024caf
Last commit: 2 weeks ago
Core tap ORIGIN: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
Core tap HEAD: 06d77104b20277c78b5a05edd782ce461d19cdf7
Core tap last commit: 13 days ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_BOTTLE_DOMAIN: https://mirrors.ustc.edu.cn/homebrew-bottles
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit westmere
Clang: 12.0 build 1200
Git: 2.24.3 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.0.1-x86_64
CLT: N/A
Xcode: 12.4
Rosetta 2: true
好了兩個版本都已成功安裝!美滋滋!安裝太慢的話,大家可以換源,像中科大,清華的都可以。