macOS系統下安裝Homebrew

macOS系統下安裝Homebrew

系統版本信息:macOS Mojave 10.14.3

接下來進入正題,最近爲了折騰Vue的環境在網上找了不少的資料,包括博客,提問啥的,發現到最後都解決不了問題,一直報錯,直到翻到了這個Mac下使用國內鏡像安裝HomebrewHomeBrew 官方安裝太慢而失敗?這麼搞就行.(轉載),受此啓發並結合自己的安裝經歷,給那篇補充一些細節,並希望給後來者一些幫助和啓發。

這裏我們使用國內鏡像安裝。在此感謝前面的兩位dalao

1.獲取install文件並編輯

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這一行,不過沒關係,新增上去就行了。

修改後代碼和截圖如下

#!/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#新增

圖片描述

2.開始安裝

/usr/bin/ruby ~/brew_install 
在這裏我沒有遇到原文下面提問的朋友遇到的卡住報錯不動等問題,僅停頓了一會兒。

3.替換源

#替換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

4.brew更新

brew update

最後:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章