这几天在 Mac 上安装 Homebrew 时遇到了一系列问题。怕是遇到问题最多的一篇记录了。问题解决一个再接一个...... 一度想放弃,为什么别人安装这么顺利。心累到想抓狂。
好在查阅了大量博客,最终得到解决。记录一下,能帮到别人是再好不过了。如有问题,请指正。
最后的成功:
Your system is ready to brew.
Homebrew
Homebrew 是一款 Mac OS 平台下简单、灵活的软件包管理工具,拥有安装、卸载、更新等等很多实用的功能。简单的指令就可以实现包管理。
Homebrew 官网.png等下要使用的 安装语句:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
对应的 卸载语句:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
安装
开始
终端 Terminal 上输入 安装命令,并回车:
如图,回车,然后输入电脑解锁密码,回车。
继续
图3.png回车继续
继续
图4.png到这里,会出现 xcode-select 提示弹窗:
弹窗.png
我这里遇到的 问题:
- 因为我已经安装了 Xcode,所以“获取 Xcode”跳转到 App Store 中,对我来说没用。
- 点击“以后”,在后续步骤会报错。
-
点击“安装”,会提示下图:
错误提示.png
尝试了 N 遍依然如此。后来回家,**换了 WiFi,就可以下载了**.....
> Note
> 如果可以正常安装,**跳过此步骤**。
尝试解决:
1 因为这里已经安装了 Xcode,Command Line Tools 也已经配置好了:
2 尝试修改路径
```
sudo xcode-select --switch /Library/Developer/CommandLineTools/
sudo xcode-select -p
```
都是无效的。
3 尝试使用 脚本文件,以便于可以继续执行下面的步骤
3.1 获取install文件
```
cd ~
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
```
搜索 brew_install 文件,并打开:
文件搜索.png 本地的文件.png
3.2 运行脚本文件
/usr/bin/ruby brew_install
继续
图10.png情况有所好转,开始有进度显示
另一个问题:
==> Downloading and installing Homebrew...
remote: Enumerating objects: 124276, done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
Failed during: git fetch origin master:refs/remotes/origin/master --tags --force
要 pull 的文件过大,需要增大缓存。所以会出现这个错误。
解决:
Git config --global http.postBuffer 524288000
重新安装
又一个错误:
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': transfer closed with outstanding read data remaining
Error: Failure while executing; `git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1` exited with 128.
Error: Failure while executing; `/usr/local/bin/brew tap homebrew/core` exited with 1.
Failed during: /usr/local/bin/brew update --force
网络问题,或者连不上服务器......
解决:
重复尝试了 3 次。
安装成功
==> Downloading and installing Homebrew...
HEAD is now at db58b9f41 Merge pull request #6219 from Homebrew/dependabot/bundler/Library/Homebrew/rspec-support-3.8.2
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 5010, done.
remote: Counting objects: 100% (5010/5010), done.
remote: Compressing objects: 100% (4784/4784), done.
remote: Total 5010 (delta 52), reused 1204 (delta 33), pack-reused 0
Receiving objects: 100% (5010/5010), 4.02 MiB | 14.00 KiB/s, done.
Resolving deltas: 100% (52/52), done.
Tapped 2 commands and 4796 formulae (5,052 files, 12.5MB).
Already up-to-date.
==> Installation successful!
......
Installation successful! 终于安装成功。
检验
使用 brew doctor 命令检查安装的 brew 是否可用。
LZCdeMacBook-Pro:~ liu$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
/anaconda3/bin/icu-config
/anaconda3/bin/krb5-config
/anaconda3/bin/freetype-config
/anaconda3/bin/xslt-config
/anaconda3/bin/libpng16-config
/anaconda3/bin/python3.7-config
/anaconda3/bin/libpng-config
/anaconda3/bin/xml2-config
/anaconda3/bin/python3.7m-config
/anaconda3/bin/python3-config
/anaconda3/bin/curl-config
/anaconda3/bin/ncursesw6-config
/anaconda3/bin/pcre-config
Warning: Xcode alone is not sufficient on Mojave.
Install the Command Line Tools:
xcode-select --install
两个警告问题:
-
Warning: "config" scripts exist outside your system or Homebrew directories.
这个错误和 Python 相关,很可能意味着使用 Homebrew 之外的工具安装 Python。如果觉得不重要,可以忽略这个警告。因为我之前直接安装的 Python,所以觉得处理这个警告。需要删除该版本的 Python,但建议先阅读操作.sudo rm -rf /Library/Frameworks/Python.framework
-
Warning: Xcode alone is not sufficient on Mojave.
这个问题需要运行 xcode-select --install 命令。也是折磨我最久的一个问题,但却是最容易解决的问题。因为当时的网络环境导致不能成功安装。换个网络环境就好了。
LZCdeMBP:~ liu$ xcode-select --install xcode-select: note: install requested for command line developer tools
以上问题都解决完后,重新检验:
LZCdeMBP:~ liu$ brew doctor
Your system is ready to brew.
Your system is ready to brew. 已经没有了警告和错误。
这次安装消耗了很多精力,在满怀希望的解决一个问题时,很有可能会失败,或者继续出现下一个问题。永远不知道离成功还有几个问题等待着你。但是继续做就好了,不要着急,解决方法总比问题多。我也是看着别人的博客,一个个问题的解决。放平心态,继续前行。
如果还有未能解决的问题,推荐看看How to install Xcode, Homebrew, Git, RVM, Ruby & Rails on Mac OS X (from Snow Leopard to Mojave)。Good Luck。
参考博客
mac 安装homobrew 报错解决
mac下brew安装软件后位置
Mac—Homebrew安装与使用
Mac安装homebrew和brew cask
关于 ReactNative 环境搭建之 error: invalid developer directory '/Library/Developer/CommandLineTools' - RN
How to install Xcode, Homebrew, Git, RVM, Ruby & Rails on Mac OS X (from Snow Leopard to Mojave)
网友评论