接下來進入正題,最近爲了折騰Vue的環境在網上找了很多的資料,包括博客,提問啥的,發現到最後都解決不了問題,一直報錯,直到翻到了這個 Mac下使用國內鏡像安裝Homebrew和 HomeBrew 官方安裝太慢而失敗?這麼搞就行.(轉載),受此啓發並結合本身的安裝經歷,給那篇補充一些細節,並但願給後來者一些幫助和啓發。這裏咱們使用國內鏡像安裝。在此感謝前面的兩位dalao。git
cd ~ curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
編輯的話直接在Finder裏面搜索brew_install,雙擊以後打開,通常會用Xcode打開。原文說的「 註釋掉BREW_REPO = "https://github.com/Homebrew/brew".freeze和CORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze」,不知爲什麼,我這兒沒有 CORE_TAP_REPO這一行,不過不要緊,新增上去就好了。
修改後代碼和截圖以下github
#!/usr/bin/ruby # This script installs to /usr/local only. To install elsewhere (which is # unsupported) you can untar https://github.com/Homebrew/brew/tarball/master # anywhere you like. HOMEBREW_PREFIX = "/usr/local".freeze HOMEBREW_REPOSITORY = "/usr/local/Homebrew".freeze HOMEBREW_CORE_TAP = "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core".freeze HOMEBREW_CACHE = "#{ENV["HOME"]}/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 = "git://mirrors.ustc.edu.cn/homebrew-core.git".freeze#新增
/usr/bin/ruby ~/brew_install
在這裏我沒有遇到原文下面提問的朋友遇到的卡住報錯不動等問題,僅停頓了一下子。
#替換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 update
最後:ruby
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile