Homebrew的安装及使用
1、官方地址
首先我们先到官方地址:https://brew.sh/
可以看到简单的安装步骤, 接下来讲解一下, 如何安装homebrew。
2、安装步骤
1) 在终端上执行命令:/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
会输出这句话:Press RETURN to continue or any other key to abort
这里直接按回车键继续。
2)输出密码
接下来就会出现这个, 输出你mac 密码
==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/bin /usr/local/etc /usr/local/lib /usr/local/share /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1
Password:
接下来会拉去很多版本的信息, 你可能会在下面的地方停住。
等待合并就好。
3)完成
当你看到下面的信息就说明完成了
==> Next steps:
- Run brew help
to get started
3、可能出现的问题
brew install XXX一直卡在Updating Homebrew
方法1: 关闭更新, 在bash_profile加入关闭参数
解决方法,关闭自动更新,
vim ~/.bash_profile
export HOMEBREW_NO_AUTO_UPDATE=true
方法2: 更换镜像源
1)跟换
替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/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://mirrors.tuna.tsinghua.edu.cn/homebrew.git
中科大镜像源: http://mirrors.ustc.edu.cn/homebrew.git
2) 还原
如果换了还是不行, 切回来,使用代理或者是网佳地方在更新
重置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
4、经验
有时一致卡着, 我们使用ctrl + c 终止, 在使用之前安装的工具, 有可能已经安装成功了, 只是在下载其他的更新而已。