安裝方法一 :
官網(wǎng)推薦安裝命令行
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
當(dāng)時(shí)經(jīng)常會(huì)報(bào)下面錯(cuò)誤
- curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused (連接被拒)
- curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection time out (連接超時(shí))
這應(yīng)該是被墻導(dǎo)致
解決辦法:
到 https://www.ipaddress.com 網(wǎng)站查詢 raw.githubusercontent.com 對應(yīng)的ip地址
修改系統(tǒng)hosts > 終端使用命令行sudo vim /etc/hosts
在里邊添加域名解析地址199.232.68.133 raw.githubusercontent.com
(199.232.68.133 是查詢到的對應(yīng)ip)
安裝方法2
參考: https://docs.brew.sh/Installation
使用命令行 sudo mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
安裝方法 3
使用命令行加載安裝腳本(如果下載不成功切換網(wǎng)絡(luò)嘗試充蓝,可以連接手機(jī)熱點(diǎn))
# 進(jìn)入根目錄
cd ~
# 下載
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
# 下載完成后找到文件打開
注釋掉 BREW_REPO = "https://github.com/Homebrew/brew".freeze
CORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze (新版本可能不存在了柿菩,直接加上下邊的就行)
修改為 BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze
CORE_TAP_REPO = "git://mirrors.ustc.edu.cn/homebrew-core.git".freeze
#修改后保存, 執(zhí)行下面命令
ruby brew_install.rb
安裝方法4
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
補(bǔ)充: 修改鏡像源
方法3安裝的不需要修改
① 替換核心軟件倉庫
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
② 替換 cask 軟件倉庫(提供 macOS 應(yīng)用和大型二進(jìn)制文件)
cd "$(brew --repo)"/Library/Taps/caskroom/homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
替換 Bottles 源(Homebrew 預(yù)編譯二進(jìn)制軟件包)
③ bash(默認(rèn) shell)用戶:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
④ zsh 用戶:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
福利環(huán)節(jié)
Rvm 官網(wǎng)
: https://www.rvm.io/
Rvm 安裝指南
:https://rvm.io/rvm/install
Ruby 官網(wǎng)
:https://rubygems.org/
CocoaPods 官網(wǎng)
:https://cocoapods.org/
Homebrew 官網(wǎng)
:http://brew.sh/index_zh-cn.html
ruby 鏡像
:
- 淘寶鏡像 https://ruby.taobao.org/ 這個(gè)不更新了
- china鏡像 https://gems.ruby-china.org/