MacOS多次踩坑后成功安装Homebrew
程序员文章站
2022-04-18 22:05:37
...
来一次性成功安装Homebrew吧
官网提供的安装脚本无法成功安装Homebrew,原因大家都懂的,故采用脚本安装的方式。
下载homebrew的安装脚本brew_install
在Download路径下执行如下脚本
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
修改brew_install脚本
修改brew_install脚本。如果你的脚本打开之后是如下内容:
#!/usr/bin/ruby
STDERR.print <<EOS
Warning: The Ruby Homebrew installer is now deprecated and has been rewritten in
Bash. Please migrate to the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
EOS
Kernel.exec "/bin/bash", "-c", '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"'
那么你需要直接打开链接Homebrew完整的install脚本,然后替换本地brew_install.sh的内容,并且修改脚本中BREW_REPO的值,如下:BREW_REPO="https://mirrors.ustc.edu.cn/brew.git"
从改镜像库中下载资源。
执行brew_install脚本
要执行该脚本,首先更改脚本的权限,执行如下命令:
chmod 755 brew_install
然后执行安装命令:
./brew_install
之后会卡住,需要执行如下脚本:
git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1
出现如下内容:
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
Press RETURN to continue or any other key to abort
==> Downloading and installing Homebrew...
HEAD is now at 270fd422d Merge pull request #7534 from MikeMcQuaid/outdated-version
Already up-to-date.
==> Installation successful!
==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
No analytics data has been sent yet (or will be during this `install` run).
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations
==> Next steps:
- Run `brew help` to get started
- Further documentation:
https://docs.brew.sh
安装就成功了。可以执行brew help验证。