mac下安装和使用brew

 

一,安装brew
curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1

2,安装完成后执行
brew
提示:Please run brew update!

3,按照提示更新,执行
brew update
报错:Error: /usr/local must be writable!

4,赋给/usr/local目录权限,执行sudo chown -R $(whoami) /usr/local,即
sudo chown -R fxp /usr/local
其中fxp为系统当前用户名。

5,再次执行
brew update
提示:
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
HEAD is now at c3f959d Merge pull request #1542 from woodruffw/deprecate-utils-json
To restore the stashed changes to /usr/local run:
'cd /usr/local && git stash pop'
==> Homebrew has enabled anonymous aggregate user behaviour analytics
Read the analytics documentation (and how to opt-out) here:
https://git.io/brew-analytics
==> Tapping homebrew/core
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 3757, done.
remote: Compressing objects: 100% (3647/3647), done.
remote: Total 3757 (delta 13), reused 305 (delta 1), pack-reused 0
Receiving objects: 100% (3757/3757), 3.00 MiB | 30.00 KiB/s, done.
Resolving deltas: 100% (13/13), done.
Checking connectivity... done.
Tapped 3636 formulae (3,784 files, 9.3M)
Already up-to-date.
Error: Could not link:
/usr/local/share/doc/homebrew

Please delete these paths and run brew update.
==> Migrating HOMEBREW_REPOSITORY (please wait)...
Error: Could not link:
/usr/local/share/doc/homebrew

Please delete these paths and run brew update.
==> Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew!
Homebrew no longer needs to have ownership of /usr/local. If you wish you can
return /usr/local to its default ownership with:
sudo chown root:wheel /usr/local

6,按照提示删除/usr/local/share/doc/homebrew,执行
rm -r -f /usr/local/share/doc/homebrew

7,再次执行
brew update

安装更新成功!

二,使用brew

命令行下执行brew,用法提示如下:
Example usage:
brew search [TEXT|/REGEX/]
brew (info|home|options) [FORMULA...]
brew install FORMULA...
brew update
brew upgrade [FORMULA...]
brew uninstall FORMULA...
brew list [FORMULA...]

Troubleshooting:
brew config
brew doctor
brew install -vd FORMULA

Developers:
brew create [URL [--no-fetch]]
brew edit [FORMULA...]
https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md

Further help:
man brew
brew help [COMMAND]
brew home

常用命令有安装和卸载等,以安装和卸载autojump为例:
安装:sudo brew install autojump
卸载:sudo brew uninstall wget

 

 

 


作者:走一朝
链接:https://www.jianshu.com/p/27d5a98144f3
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

 

3.替换homebrew镜像源(自己选择)

由于homebrew上面的东西 很多要么被墙,要么死慢,需要换brew源(分为两部分)

 

替换homebrew默认源

  cd "$(brew --repo)"   //这个命令会进入到相应目录,可以pwd查看下

  cd "$(brew --repo)" git remote set-url origin git://mirrors.ustc.edu.cn/brew.git

Homebrew Bottles源(二进制代码包)

  echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile

  source ~/.bash_profile

更新

  brew update

4.brew被墙的另一种解决

因为 brew 是支持全局代理的,我们只需要在当前环境当中加入代理配置即可。我跳出去的软件是shadowsocks(不懂得自行百度即可),当然,如果你选择了上面的换源操作,可以忽略这里

 

只需在命令行中输入 export ALL_PROXY=socks5://127.0.0.1:1080

 

如果你想一劳永逸,就将其写在配置文件中,

如果你的终端是默认的bash就写在~/.bash+profile中,

echo export ALL_PROXY=socks5://127.0.0.1:1080 >> ~/.bash_profile

如果你的终端是zsh,那就写在~/.zshrc中

echo export ALL_PROXY=socks5://127.0.0.1:1080 >> ~/.zsh_profil

不过以上的弊端就是,可能你大部分终端的命令都会使用代理了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值