macOS 开发必备环境安装
更新时间: 2025/9/22 | 总字数: 0 字 | 阅读时长: 0 分钟
Homebrew
官方网址:https://brew.sh
安装 Hombrew
shell
$ /bin/bash -c "$(curl -fsSL https://github.com/Homebrew/install/raw/master/install.sh)"或者
shell
$ /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"查看 Homebrew 版本
shell
$ brew -v替换 Homebrew 源
shell
$ echo 'export HOMEBREW_API_DOMAIN="https://mirrors.aliyun.com/homebrew-bottles/api"' >> ~/.bash_profile
$ echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/brew.git"' >> ~/.bash_profile
$ echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/homebrew-core.git"' >> ~/.bash_profile
$ echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.aliyun.com/homebrew/homebrew-bottles"' >> ~/.bash_profile
$ source ~/.bash_profile
$ brew updateshell
$ echo 'export HOMEBREW_API_DOMAIN="https://mirrors.aliyun.com/homebrew-bottles/api"' >> ~/.zshrc
$ echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/brew.git"' >> ~/.zshrc
$ echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/homebrew-core.git"' >> ~/.zshrc
$ echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.aliyun.com/homebrew/homebrew-bottles"' >> ~/.zshrc
$ source ~/.zshrc
$ brew update恢复默认配置
提示
恢复默认设置时,如在配置文件中设置了 HOMEBREW 环境变量,还需要将对应的环境变量配置进行删除。
重置 Homebrew
shell
$ git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew
$ git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
$ brew update手动删除环境变量
zsh用户:编辑~/.zshrc文件。bash用户:编辑~/.bash_profile配置文件。
删除之前配置的记录:
shell
$ export HOMEBREW_API_DOMAIN="https://mirrors.aliyun.com/homebrew-bottles/api"
$ export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/brew.git"
$ export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.aliyun.com/homebrew/homebrew-core.git"
$ export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.aliyun.com/homebrew/homebrew-bottles"卸载 Homebrew
shell
$ /bin/bash -c "$(curl -fsSL https://github.com/Homebrew/install/raw/master/uninstall.sh)"或者
shell
$ /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"