Homebrew 慢,每次 search 都要联网,install 也要先更新

搜索个包名要等好久,加 -d 提示要连个网,好像没法关闭。类似的每次 install 都要先更新,也很慢。

~ $ time brew search qr
==> Formulae
liblqr                                       qrcp                                         qrencode                                     qrupdate
==> Casks
homebrew/cask/qr-journal
brew search qr  6.36s user 1.19s system 70% cpu 10.765 total
~ $ time brew search -d qr
/usr/bin/curl --disable --globoff --show-error --user-agent Homebrew/2.5.11-41-gf00e094\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 10.15.7\)\ curl/7.64.1 --header Accept-Language:\ en --retry 3 --location https://api.github.com/search/code\?q=user\%3AHomebrew\+path\%3AFormula\+path\%3ACasks\+path\%3A.\+filename\%3Aqr\+extension\%3Arb\&per_page=100 --header Accept:\ application/vnd.github.v3\+json --write-out '
'\%\{http_code\} --header Accept:\ application/vnd.github.antiope-preview\+json --dump-header /private/tmp/github_api_headers20201119-56704-c8zq8u
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/liblqr.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::AliasLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/qrencode.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/qrcp.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/qrupdate.rb
==> Formulae
liblqr                                       qrcp                                         qrencode                                     qrupdate
==> Casks
homebrew/cask/qr-journal
brew search -d qr  6.32s user 1.43s system 59% cpu 12.990 total
~ $

科学上网. shell 配置代理, 能彻底解决这个问题.

export HOMEBREW_NO_AUTO_UPDATE=1
1 个赞

Nice!还是要看手册啊。还有这个选项应该就能搜索不联网

HOMEBREW_NO_GITHUB_API

If set, do not use the GitHub API, e.g. for searches or fetching relevant issues after a failed install.

但是不联网了,这个命令还是很慢,从 6s 变成 5s

~ $ time brew search -d qr
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/liblqr.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::AliasLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/qrencode.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/qrcp.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/qrupdate.rb
==> Formulae
liblqr                                       qrcp                                         qrencode                                     qrupdate
brew search -d qr  5.06s user 0.53s system 97% cpu 5.748 total
~ $

听说 Apple 新的 M1 芯片有个什么安全模块开机就得联网 :sweat:

本地搜索没结果的时候才需要用到 GITHUB API 吧。本地有结果关不关应该没区别。

这个问题也是一直困扰着我,加了代理好很多。真的很想换成Nix,但又怕nix 软件不够多。有人在mac 上只用Nix的吗?

貌似不是,一上来就连 github api,有没有匹配都是。

现在是这样了?我已经6个月没更新。