mac安裝homebrew
在mac上安裝軟件,都會用到homebrew,第一次安裝,有很多坑,這里記錄一下
-
homebrew是國外源,安裝特別慢,切不容易裝好----》使用國內源
-
安裝wget軟件報錯
wget: Failed to download resource "gettext" Download failed: https://ghcr.io/v2/homebrew/core/gettext/blobs/sha256:a025e143fe3f5f7e24a936b8b0a4926acfdd025b11d62024e3d355c106536d56
問題是:homebrew的HOMEBREW_BOTTLE_DOMAIN地址沒有或者不對。下面來看看這兩個問題的解決方案。
一、macOS 安裝 homebrew 國內源
背景
在安裝 homebrew 時,用官網的安裝方法很慢且容易中斷,所以想到使用國內的源進行安裝。
Homebrew 科大源
我們將安裝源地址設置為 https://raw.githubusercontent.com/Homebrew/install/master/install.sh
即進行一下操作:
cd ~
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brew_install
在終端用 open -e brew_install
或者在訪達中直接搜索整台Mac home_brew
雙擊打開。
#BREW_REPO="https://github.com/Homebrew/brew" #用第二行內容更換該行內容
BREW_REPO="git://mirrors.ustc.edu.cn/brew.git"
保存之后,在終端中輸入/bin/bash brew_install
進行快速安裝。
在安裝過程中會卡在
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
於是可以直接 control c
結束,並直接使用 𝑈𝑆𝑇𝐶USTC 源進行更換。
mkdir -p /usr/local/Homebrew/Library/Taps/homebrew/
cd /usr/local/Homebrew/Library/Taps/homebrew
git clone https://mirrors.ustc.edu.cn/homebrew-core.git
配置完成后終端輸入brew help
顯示幫助信息則說明安裝成功,如果提示失敗請檢查 /usr/local/bin 下是否有 brew,有的話添加環境變量即可。
檢查操作
cd /usr/local/bin
ls | grep brew
二、安裝wget軟件報錯
1.報錯信息
在安裝wget的報錯,報錯信息如下:
==> Downloading https://ghcr.io/v2/homebrew/core/gettext/manifests/0.21
Already downloaded: /Users/aaa/Library/Caches/Homebrew/downloads/66569d4eb02ec67195446d3dcba7d7806a35f88f629a55b43ba53fb1febb1f56--gettext-0.21.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/gettext/blobs/sha256:a025e143fe
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
################### 27.3%
curl: (92) HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
Error: wget: Failed to download resource "gettext"
Download failed: https://ghcr.io/v2/homebrew/core/gettext/blobs/sha256:a025e143fe3f5f7e24a936b8b0a4926acfdd025b11d62024e3d355c106536d56
2.查看HOMEBREW_BOTTLE_DOMAIN地址
運行brew config, 查看HOMEBREW_BOTTLE_DOMAIN的地址
brew config
輸出的地址中沒有HOMEBREW_BOTTLE_DOMAIN,或者是HOMEBREW_BOTTLE_DOMAIN: https://mirrors.ustc.edu.cn/homebrew-bottles 都不行。后者地址是錯誤的。

我的是里面沒有這個地址。所以需要添加地址
3.添加HOMEBREW_BOTTLE_DOMAIN地址
查閱了[Homebrew Bottles 源使用幫助],正確的地址是:
https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/
於是,修改HOMEBREW_BOTTLE_DOMAIN的地址。
執行命令:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.zshrc
source ~/.zshrc
4.檢查修改結果
再運行一次brew config

5.重新安裝wget
brew install wget

成功!