溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

怎么在Mac M1中安裝Homebrew

發(fā)布時間:2021-03-25 15:29:45 來源:億速云 閱讀:693 作者:Leah 欄目:開發(fā)技術

怎么在Mac M1中安裝Homebrew?針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。

常用命令

搜索軟件: brew search 軟件包名稱

安裝軟件: brew install 軟件包名稱

卸載軟件: brew uninstall 軟件包名稱

錯誤解決

問題1 : curl: (7) Failed to connect to http://raw.githubusercontent.com port 443: Connection refused” 錯誤

解決方法:

打開 www.ipaddress.com 網(wǎng)站查詢 raw.githubusercontent.com 主機的真實IP

怎么在Mac M1中安裝Homebrew

打開 /etc/hosts 文件,增加一條記錄

185.199.108.133  raw.githubusercontent.com

問題2 :如果 brew install 出以下錯誤, 則安裝時使用 arch -arm64 brew install 軟件包名 進行安裝

怎么在Mac M1中安裝Homebrew

創(chuàng)建安裝目錄

Homebrew 安裝腳本會將程序默認裝至 /usr/local/Homebrew ,這是 Intel 芯片架構(gòu)上的安裝路徑,M1芯片上則需要安裝到 /opt/Homebrew/ 下。

sudo mkdir -p /opt/homebrew
sudo chown -R $(whoami) /opt/homebrew

下載 homebrew 包并解壓至 /opt/homebrew 目錄

curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

如果下載慢,可以直接通過 https://github.com/Homebrew/brew/tarball/master 或本地下載,copy 到 /opt 目錄下再將壓縮包解壓到 /opt/homebrew 目錄

cp /opt
tar xz 壓縮包名 --strip 1 -C homebrew

將路徑增加到PATH環(huán)境變量中

vim ~/.bash_profile
#在 .bash_profile 中新增
export PATH=$PATH:/opt/homebrew/bin;
#保存退出
#刷新生效
source ~/.bash_profile

修改源

cd "$(brew --repo)"
git clone https://mirrors.ustc.edu.cn/brew.git
 
 
cd "$(brew --repo)/Library/Taps/homebrew"
 
git clone https://mirrors.ustc.edu.cn/homebrew-core.git
 
git clone https://mirrors.ustc.edu.cn/homebrew-cask.git
 
brew update #更新

其它鏡像地址:

HomeBrew 官方鏡像:
brew: https://github.com/Homebrew/brew
core: https://github.com/Homebrew/homebrew-core
cask: https://github.com/Homebrew/homebrew-cask

清華大學鏡像:
brew: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
core: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
cask: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

中科大鏡像:
brew: https://mirrors.ustc.edu.cn/brew.git
core: https://mirrors.ustc.edu.cn/homebrew-core.git
cask: https://mirrors.ustc.edu.cn/homebrew-cask.git

終于可以進行下載軟件了

brew install -s 軟件包名

關于怎么在Mac M1中安裝Homebrew問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業(yè)資訊頻道了解更多相關知識。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

AI