1. 程式人生 > 程式設計 >Mac M1安裝Homebrew的方法步驟

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 網站查詢 raw.githubusercontent.com 主機的真實IP

Mac M1安裝Homebrew的方法步驟

開啟 /etc/hosts 程式設計客棧檔案,增加一條記錄

185.199.108.133  raw.githubu
程式設計客棧
sercontent.com

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

Mac M1安裝Homebrew的方法步驟

建立安裝目錄

Homebrew 安裝指令碼會將程式預設裝至 /usr/local/Homebrew ,這是 Intel 晶片架構上http://www.cppcns.com的安裝路徑,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環境變數中

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://gitwww.cppcns.comhub.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的方法步驟的文章就介紹到這了,更多相關M1安裝Homebrew內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援我們!