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
來源:簡書
著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。