侧边栏壁纸
  • 累计撰写 73 篇文章
  • 累计创建 30 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录
Mac

M1芯片Mac上Homebrew安装

欧泡果奶
2022-04-15 / 0 评论 / 0 点赞 / 621 阅读 / 0 字

ARMHomebrew最终被安装在/opt/homebrew路径下。

1. 执行安装脚本

/bin/bash -c "$(curl -fsSL https://cdn.ochaly.com/homebrew/install.sh)"

2. 设置环境变量

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

3. 安装cask

brew tap homebrew/cask

补充:

1. 多版本共存

1.1 安装 X86 版 Homebrew

因为目前很多软件包没有支持ARM架构,我们也可以考虑使用x86版的Homebrew

在命令前面添加arch -x86_64,就可以按 X86 模式执行该命令,比如:

arch -x86_64 /bin/bash -c "$(curl -fsSL https://cdn.ochaly.com/homebrew/install.sh)"
1.2 配置环境变量
cat >> ~/.zprofile <<EOF
alias abrew='arch -arm64 /opt/homebrew/bin/brew'
alias ibrew='arch -x86_64 /usr/local/bin/brew'
EOF

source ~/.zprofile

abrewibrew可以根据你的喜好自定义。

2. 卸载 Homebrew

/bin/bash -c "$(curl -fsSL https://cdn.ochaly.com/homebrew/uninstall.sh)"

3. 安装 homebrew-rmtree 自动删除软件依赖

# 安装
brew tap beeftornado/rmtree

# 使用
brew rmtree xxx

4. 设置镜像

brewhomebrew/core是必备项目,homebrew/caskhomebrew/bottles按需设置。

通过 brew config 命令可以查看相关配置信息。

4.1 中科大源
# brew
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git

# core
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

# cask
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

# bottles for zsh 和下面2选1
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.zprofile
source ~/.zprofile

# bottles for bash 和上面2选1
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.bash_profile
source ~/.bash_profile

brew update
4.2 清华大学源
# brew
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

# core
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

# cask
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

# bottles for zsh 和下面2选1
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles' >> ~/.zprofile
source ~/.zprofile

# bottles for bash 和上面2选1
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles' >> ~/.bash_profile
source ~/.bash_profile

brew update

5. 批量更新

brew upgarde

6. 锁定不想更新的包

# 锁定某个包
brew pin 软件名

# 取消锁定
brew unpin 软件名
0

评论区