Mac下使用國內鏡像安裝Homebrew


根據官網上的方法,在終端輸入:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

結果還是被卡在下載階段,怎么辦呢?於是上網搜索到了“Homebrew 的安裝方法(官方的方法老是安裝失敗) 第三方”這篇文章。

依文中所述,進行安裝。由於官方棄用了舊的homebrew倉庫,將homebrew程序與軟件包拆分成了兩個倉庫。與文中描述不符,也未能成功安裝。於是稍作修改,記錄於此。

國內的鏡像

新增brew.git與homebrew-core.git鏡像

由於官方棄用了舊的homebrew倉庫,將homebrew程序與軟件包拆分成了兩個倉庫。為保證用戶正常升級,舊鏡像將暫時保留一段時間,擇期刪除。

倉庫對應關系:

github.com/Homebrew/brew -> mirrors.ustc.edu.cn/brew.git
github.com/Homebrew/homebrew-core -> mirrors.ustc.edu.cn/homebrew-core.git
github.com/Homebrew/homebrew(棄用) -> mirrors.ustc.edu.cn/homebrew.git

引自:新增brew.git與homebrew-core.git鏡像

安裝

獲取install文件並編輯

cd ~ curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install 

編輯brew_install文件

#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby # This script installs to /usr/local only. To install elsewhere you can just # untar https://github.com/Homebrew/brew/tarball/master anywhere you like or # change the value of HOMEBREW_PREFIX. HOMEBREW_PREFIX = "/usr/local".freeze HOMEBREW_REPOSITORY = "/usr/local/Homebrew".freeze HOMEBREW_CACHE = "#{ENV["HOME"]}/Library/Caches/Homebrew".freeze HOMEBREW_OLD_CACHE = "/Library/Caches/Homebrew".freeze #BREW_REPO = "https://github.com/Homebrew/brew".freeze BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze #CORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze CORE_TAP_REPO = "git://mirrors.ustc.edu.cn/homebrew-core.git".freeze 

注釋掉BREW_REPO = "https://github.com/Homebrew/brew".freezeCORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze

修改為BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freezeCORE_TAP_REPO = "git://mirrors.ustc.edu.cn/homebrew-core.git".freeze

安裝

/usr/bin/ruby ~/brew_install 

運行修改了的brew_install文件。

替換homebrew源

替換homebrew默認源

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

替換homebrew-core源

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

brew更新

brew update

設置 bintray鏡像

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



作者:采姑娘的小魔鈷
鏈接:https://www.jianshu.com/p/6523d3eee50d


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM