← Back to archive
Programming Notes

Updating Brew When It's Blocked on Mac

Running

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


When installing with this command, it reported that GitHub was inaccessible and brew could not be downloaded.

So the only option was

git clone git://mirrors.tuna.tsinghua.edu.cn/homebrew.git (or git clone http://mirrors.ustc.edu.cn/homebrew.git)


Download, then copy into the /usr/local folder.

After trying

git remote set-url origin http://mirrors.ustc.edu.cn/homebrew.git



and then running brew update, it still said GitHub was inaccessible—quite strange.


I thought of two approaches: one was to modify brew's scripts to force a specific setting, but that was too much trouble.

So in the end I used ShadowsocksX-NG, connected directly to the server, opened port 1087 as an HTTP proxy, and in the terminal used:

export https_proxy=http://127.0.0.1:1087


Then brew succeeded.

Written by Master Sanfu on December 17, 2016. Please credit the source if you share.

Translation Notice: This English version was translated with AI assistance. Specialized, historical, religious, or culturally sensitive terms may contain nuances, inaccuracies, or debatable wording. In case of ambiguity or discrepancy, the original Chinese text shall prevail.