一,MAC安装Homebrew
####1, 安装homebrew 建议大家去Homebrew官网去安装,网上博客给出的连接,不安全,也不稳定,可能会导致Homebrew装偏(我就遇到了这个问题)
检查ruby是否安装:
ruby --version
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
执行安装homebrew指令:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
当brew安装成功后,就可以随意安装自己想要的软件了,例如wget,命令如下:
sudo brew install wget
卸载的话,命令如下:
sudo brew uninstall wget
查看安装软件的话,命令如下:
sudo brew search /apache*/
注意/apache*/是使用的正则表达式,用/分割。
####2, 卸载homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
问题: 安装完homebrew之后,用homebrew安装工具包的时候,提示没有权限,如下:
error: could not lock config file .git/config: Permission denied
Error: Failure while executing: git config --local --replace-all homebrew.private false
解决办法: 执行下面两条指令:
//确保目录归属管理组
sudo chgrp -R admin /usr/local
//确保管理组可读
sudo chmod -R g+w /usr/local
然后就可以正常安装程序包了;
替换homebrew源
Homebrew作为Mac os系统的包管理器,给软件的安装和更新等带来了极大地便利,但使用过程中总会遇到软件下载特别慢的问题,通过将默认源更改为国内的镜像地址,可以极大地提高下载速度。下面是收集的一些最新的更改默认源的操作(在终端里执行代码):
更换为清华源
更换brew.git
cd "$(brew --repo)"
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.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
更换Home Bottles源
长期更换:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
临时更换:
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
更换为中科大源
更换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
更换Home cask软件仓库
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
更换Home Bottles源
长期更换:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
临时更换:
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
重置默认源
重置brew.git
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
重置Homebrew cask软件仓库
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
git remote set-url origin https://github.com/Homebrew/homebrew-cask
重置Homebrew Bottles源
注释掉bash配置文件里的有关Homebrew Bottles即可恢复官方源。 重启bash或让bash重读配置文件。