0%

macOS Big Sur 11.1 Arm架构安装使用Homebrew

安装Hombrew国内脚本版

1
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

会将Homebrew安装在intel架构的默认目录下

1
/usr/local/

在m1芯片 arm架构下的Big Sur系统下运行

(例:比如安装lrzsz)

brew install lrzsz

提示:Error: 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

大多数应用其实是可以使用的,Homebrew只是限制了应用所在的路径,无需重新下载直接复制一个到/opt/Homebrew

新路径的使用

alias abrew=”/opt/homebrew/bin/brew”

旧的可以不管他,直接brew就可以用,有的人重新定义了

alias xbrew=”arch -x86_64 /usr/local/bin/brew”

这样,使用abrew命令,就可以在arm下使用了,大部分应用应该是没问题的。

本次主要是为了配置iterm2使用lrzsz,需修改脚本中的路径为新路径的,脚本也可放到其他位置,注意同步修改iterm2中的配置。

lrzsz部分参考:

https://blog.csdn.net/JENREY/article/details/103478953

参考:

https://realazy.com/til/2020-11-21-homebrew-on-macbook-pro-m1.html

切换国内源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 替换brew.git:
cd "$(brew --repo)"
# 中国科大:
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 清华大学:
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
# 中国科大:
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 清华大学:
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

# 替换homebrew-bottles:
# 中国科大:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
# 清华大学:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

# 应用生效:
brew update

切换阿里源

1
2
3
4
5
6
7
8
9
10
11
# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

切换回官方源

1
2
3
4
5
6
7
# 重置brew.git:
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

# 重置homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
坚持原创技术分享,您的支持将鼓励我继续创作!

欢迎关注我的其它发布渠道