Homebrew 安裝包失敗 & 切換源 & 安裝緩慢


受某篇隊列相關的教程安利,它簡單的寫下了 brew install rabbitmq 就開始介紹知識。筆者信了它的邪,裝此包時,從 23:00 一直到 1:30,其中切換了兩個源才解決 brew update 慢的問題,切換了控制台的梯子代理才解決下下載一個 github 上的 280MB 的包非常慢的問題,過程中還遇到了 Error: Permission denied 讓我上火的事情。

下面我們開始第一步

$ brew install rabbitmq
Updating Homebrew...
==> Installing dependencies for rabbitmq: openssl@1.1, libpng, wxmac and erlang
==> Installing rabbitmq dependency: openssl@1.1
==> Downloading https://homebrew.bintray.com/bottles/openssl@1.1-1.1.1d.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/d7/d7f992ebfd78f80828051f6dc6a1a99aed405f86b0f39ea651fd0afeadd1b0f4?__gda__=exp=1575992421~hmac=b48a88a6d35b1220627bfad07c5a04984d66b
######################################################################## 100.0%
==> Pouring openssl@1.1-1.1.1d.catalina.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

and run
  /usr/local/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because openssl/libressl is provided by macOS so don't link an incompatible version.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

==> Summary
🍺  /usr/local/Cellar/openssl@1.1/1.1.1d: 7,983 files, 17.9MB
==> Installing rabbitmq dependency: libpng
==> Downloading https://homebrew.bintray.com/bottles/libpng-1.6.37.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/c8/c8e74da602c21f978cd7ee3d489979b4fc6681e71f678a1d99012943ee3a909f?__gda__=exp=1575992686~hmac=4d6ee4ada7eb7957714e216640b9a0dd005fa
######################################################################## 100.0%
==> Pouring libpng-1.6.37.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/libpng/1.6.37: 27 files, 1.2MB
==> Installing rabbitmq dependency: wxmac
==> Downloading https://homebrew.bintray.com/bottles/wxmac-3.0.4_2.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/76/763d404a9adfadf2fa2099df378e6fb360b2b862c86e7e79413df9ed6e0da7a4?__gda__=exp=1575992702~hmac=2a59130d1b77ebbd7a3bc28491f7845762fb0
######################################################################## 100.0%
==> Pouring wxmac-3.0.4_2.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/wxmac/3.0.4_2: 810 files, 22.9MB
==> Installing rabbitmq dependency: erlang
==> Downloading https://homebrew.bintray.com/bottles/erlang-22.1.4.catalina.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/8b/8b6c056f129a6677a9886c8fd9972ec13bd25d2f79819acb556e461668d3ea34?__gda__=exp=1575992739~hmac=d2eaedbb42c65514d514e88e3e5caf8e9f22f
######################################################################## 100.0%
==> Pouring erlang-22.1.4.catalina.bottle.tar.gz
==> Caveats
Man pages can be found in:
  /usr/local/opt/erlang/lib/erlang/man

Access them with `erl -man`, or add this directory to MANPATH.
==> Summary
🍺  /usr/local/Cellar/erlang/22.1.4: 5,768 files, 280.2MB
==> Installing rabbitmq
==> Downloading https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.0/rabbitmq-server-generic-unix-3.8.0.tar.xz
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/924551/71891480-e44b-11e9-80fd-c06739f04c5e?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AK
#                                                                          1.8%
curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
Error: An exception occurred within a child process:
  DownloadError: Failed to download resource "rabbitmq"
Download failed: https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.0/rabbitmq-server-generic-unix-3.8.0.tar.xz

卡到了着!於是我單獨去下載了此文件 rabbitmq-server-generic-unix-3.8.0.tar.xz,並拷貝到 brew 的目錄下

$ brew --cache
/Users/everlose/Library/Caches/Homebrew

$ cp /Users/everlose/Downloads/rabbitmq-server-generic-unix-3.8.0.tar.xz /Users/everlose/Library/Caches/Homebrew

然后在運行安裝命令,發現卡在

$ brew install rabbitmq --verbose
Updating Homebrew...

這次連 update 都進行不下去!抓狂!!!

調試 verbose

$ brew update --verbose
Checking if we need to fetch /usr/local/Homebrew...
Checking if we need to fetch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...
Fetching /usr/local/Homebrew...
Checking if we need to fetch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...

進行不下去了,得,通通把源都切換去國內得吧,切換成中科大的,鏈接這里:https://lug.ustc.edu.cn/wiki/mirrors/help/brew.git,步驟如下:

# 替換brew.git:
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

# 替換homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

# 替換homebrew-cask
$ cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

再替換Homebrew Bottles源,參考 Homebrew Bottles 源使用幫助

# 對於 bash 用戶
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

再次更新就非常成功。

$ brew update --verbose
Checking if we need to fetch /usr/local/Homebrew...
Checking if we need to fetch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...
Fetching /usr/local/Homebrew...
Checking if we need to fetch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask...
Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
remote: Counting objects: 8714, done.
remote: Compressing objects: 100% (3829/3829), done.
remote: Total 8714 (delta 6404), reused 7173 (delta 4885)
Receiving objects: 100% (8714/8714), 5.64 MiB | 946.00 KiB/s, done.
Resolving deltas: 100% (6404/6404), completed with 976 local objects.
From https://mirrors.ustc.edu.cn/homebrew-cask
   18d8097421..1ee436843e  master     -> origin/master
Updating /usr/local/Homebrew...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Switched to and reset branch 'master'
Your branch is up to date with 'origin/master'.
Switched to and reset branch 'stable'
Current branch stable is up to date.

.......

然后繼續安裝,下載到一半又卡住了,因為它要去 github 上下載一個 278 MB的東西,下載速度真的太感人了,我臨時配置一下,讓終端能走我配置的 v two ray 代理。如果你沒有梯子,那么恭喜你要忍受極度慢的下載速度了。

export ALL_PROXY=socks5://127.0.0.1:1080

# 事后想取消全局代理的話
export ALL_PROXY=""
# 不行的話試試
unset ALL_PROXY;

特么的,下載沒問題了,但是權限又出麻煩,詳見 https://github.com/Homebrew/homebrew-core/issues/45009

Error: Permission denied @ apply2files - /usr/local/lib/node_modules/hexo/node_modules/nunjucks/node_modules/micromatch/lib/.DS_Store

刪除這個毛文件,再次安裝其實還出現了兩次 .DS_Store 的權限問題,都刪光后安裝就搞定了。

$ rm -rf /usr/local/lib/node_modules/hexo/node_modules/nunjucks/node_modules/micromatch/lib/.DS_Store
...
$ brew install rabbitmq

Warning: rabbitmq 3.8.2 is already installed and up-to-date
To reinstall 3.8.2, run `brew reinstall rabbitmq`

然后啟動試試

進入安裝目錄
$ /usr/local/Cellar/rabbitmq/3.8.2
啟動
$ sbin/rabbitmq-server

瀏覽器輸入 http://localhost:15672/#/

默認用戶名密碼 guest 訪問


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM