Mac入门--通过homebrew下载过慢问题
https://www.cnblogs.com/jingxiaoniu/p/11123377.html
使用国内的镜像替换homebrew镜像,对镜像进行加速源
原先我们执行brew命令安装的时候,跟3个仓库地址有关
1 brew.git
2 homebrew-core.git
3 homebrew-bottles
把三个仓库地址全部替换成国内Alibaba提供的地址
1 替换/还原brew.git仓库地址
1
2
3
4
5
6
7
8
9
|
# 替换成阿里巴巴的 brew.git 仓库地址: cd "$(brew --repo)" git remote set -url origin https: //mirrors.aliyun.com/homebrew/brew.git #======================================================= # 还原为官方提供的 brew.git 仓库地址 cd "$(brew --repo)" git remote set -url origin https: //github.com/Homebrew/brew.git |
2 替换/还原homebrew-core.git仓库地址
1
2
3
4
5
6
7
8
9
|
# 替换成阿里巴巴的 homebrew-core.git 仓库地址: cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set -url origin https: //mirrors.aliyun.com/homebrew/homebrew-core.git #======================================================= # 还原为官方提供的 homebrew-core.git 仓库地址 cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set -url origin https: //github.com/Homebrew/homebrew-core.git |
3 替换/还原homebrew-bottles
3.1 这个步骤跟你的macOs系统使用的shell版本有关系,首先查看shell版本
1
2
3
4
|
echo $SHELL # 如果你的输出结果是 /bin/zsh,参考?的 zsh 终端操作方式 # 如果你的输出结果是 /bin/bash,参考?的 bash 终端操作方式 |
3.2 zsh终端操作方式
1
2
3
4
5
6
7
8
9
10
|
# 替换成阿里巴巴的 homebrew-bottles 访问地址: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc source ~/.zshrc #======================================================= # 还原为官方提供的 homebrew-bottles 访问地址 vi ~/.zshrc # 然后,删除 HOMEBREW_BOTTLE_DOMAIN 这一行配置 source ~/.zshrc |
3.3 bash终端操作方式
1
2
3
4
5
6
7
8
9
10
|
# 替换 homebrew-bottles 访问 URL: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile #======================================================= # 还原为官方提供的 homebrew-bottles 访问地址 vi ~/.bash_profile # 然后,删除 HOMEBREW_BOTTLE_DOMAIN 这一行配置 source ~/.bash_profile |
mac下安装和使用brew
一,安装brew
1,安装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:
==> 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
查看安装软件的话,命令如下:
sudo brew search /apache*/
注意/apache*/是使用的正则表达式,用/分割。
原地址:http://blog.csdn.net/fxp850899969/article/details/53284193
前言:想学习一下Erlang,想通过homebrew安装一下环境,才发现新电脑还没有安装。通过官方命令在终端上安装时,发现小水管实在无法让人忍受。
于是只能通过国内镜像来安装啦,中间也遇到点问题下面把过程记录一下。
下面使用清华镜像
1.通过编辑install文件来使用镜像地
1.1获取brew_install
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_instal
1.2编辑brew_instal
vim brew_instal
1.3在Vim模式下,按i,进入编辑模式,在BREW_REPO和CORE_TAP_REPO前加#注释掉,写入镜像地址代替
BREW_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git".freeze
CORE_TAP_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git".freeze
1.4按ESC退出编辑模式,输入:wq Return保存退出
2安装
2.1安装,运行install
/usr/bin/ruby ~/brew_install
2.2 出现如下代码时,不用等了,直接关掉命令窗口
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
2.3进入下面的 Taps 目录,clone homebrew-core
cd /usr/local/Homebrew/Library/Taps/homebrew
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
3把homebrew repo切换为清华镜像
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.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
brew update
4 这时,终端会显示Already up-to-date.到此,homebrew就安装完毕了,我可以去安装Erlang啦
作者:NGC_6960
链接:https://www.jianshu.com/p/67db55780450
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。