brew install 命令卡在 Updating Homebrew 的原因与解决方法

5,305次阅读
没有评论

共计 1990 个字符,预计需要花费 5 分钟才能阅读完成。

提醒:本文最后更新于2019-07-23 10:12,文中所关联的信息可能已发生改变,请知悉!

brew 在 install 前会默认执行 brew update,它会从 brew 在 Github 的官方源码仓库进行更新。由于 Github 访问速度慢或无法访问而导致更新卡住或失败。

那么我们可以将默认的 Github 源码地址修改为国内的镜像地址来解决这个问题。

1 brew 使用国内镜像源

使用中科大镜像源,步骤参考如下:

# brew
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# homebrew-core.git
cd "$(brew --repo homebrew/core)"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 替换 homebrew-cask:如果安装了 cask,这一步也要做
cd "$(brew --repo homebrew/cask)"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
# 设置二进制预编译包镜像
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
# 测试一下
brew update

另外还有清华镜像源可选,步骤参考如下:

# 替换 brew
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 替换 homebrew-core
cd "$(brew --repo homebrew/core)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# 设置二进制预编译包镜像
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
# 最后测试一下
brew update

参考地址: https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/

2 还原默认的 Github 源码仓库地址

如果想还原为 Github 官方默认的源码仓库地址,可以按如下步骤操作:

cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://github.com/Homebrew/homebrew-cask.git
brew update

3 附:brew 安装与常用命令

brew 是 mac os x 上最流行的包管理工具,使用它安装软件非常的方便。如果你没有安装,那么安装它:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew cask k 是 brew 的一个子集,也就是一个扩展,主要用于有GUI的软件。安装 brew cask

 brew install caskroom/cask/brew-cask

brew 常用命令参考:

brew update #更新brew可安装包,建议每次执行一下
brew search php55 #搜索php5.5
brew tap josegonzalez/php #安装扩展<gihhub_user/repo>
brew tap #查看安装的扩展列表
brew install php55 #安装php5.5
brew remove php55 #卸载php5.5
brew upgrade php55 #升级php5.5
brew options php55 #查看php5.5安装选项
brew info php55 #查看php5.5相关信息
brew home php55 #访问php5.5官方网站

正文完
 0
任侠
版权声明:本站原创文章,由 任侠 于2010-07-08发表,共计1990字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
验证码