Mac國內鏡像源安裝homebrew(排雷)


獲取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


主要是排雷,如上方法在安裝時會得到如下錯誤:

Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...

fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 

Error: Failure while executing: git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

Error: Failure while executing: /usr/local/bin/brew tap homebrew/core

Failed during: /usr/local/bin/brew update --force

這個錯誤的原因還不知道是為什么(上面明明已經改了源的),在這里研究了一下,可以試着打開https://

mirrors.ustc.edu.cn/brew.git ,看到地址其實是好的,那么就是git 的clone 失敗了,那解決辦法就是我們自己clone一下

1.首先進入下載了一半的brew目錄

cd "$(brew --repo)"
2.進入准備下載homebrew-core的目錄
cd Library/Taps/
在這里建立兩層目錄

mkdir homebrew

cd homebrew/

mkdir homebrew-core

3.進入目錄

cd homebrew-core/

4.開始clone

git clone git://mirrors.ustc.edu.cn/homebrew-core.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

一會就下載完了。brew就可以用了。 


免責聲明!

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



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