Mac环境 安装brew

一。brew官网主页上的方法:

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

结果:

==> 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...
remote: Counting objects: 247, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 247 (delta 196), reused 201 (delta 196), pack-reused 46
Receiving objects: 100% (247/247), 45.99 KiB | 37.00 KiB/s, done.
Resolving deltas: 100% (204/204), completed with 71 local objects.
From https://github.com/Homebrew/brew
96eb404af..3a99e6464 master -> origin/master
HEAD is now at 3a99e6464 Merge pull request #4593 from reitermarkus/curl-options
fatal: unable to access 'https://github.com/Homebrew/brew/': SSLRead() return error -9806
Error: Fetching /usr/local/Homebrew failed!
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': SSLRead() return error -9806
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

结论:安装失败。

注意:无论翻墙与否都链接不上,只能换方法。

二。使用国内镜像

1. 生成文件
cd ~ curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install

编辑生成的文件brew_install,并且修改2个配置项:
#BREW_REPO = "https://github.com/Homebrew/brew".freeze
BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freeze
#CORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze
CORE_TAP_REPO = "git://mirrors.ustc.edu.cn/homebrew-core.git".freeze

注释掉BREW_REPO = "https://github.com/Homebrew/brew".freezeCORE_TAP_REPO = "https://github.com/Homebrew/homebrew-core".freeze

修改为BREW_REPO = "git://mirrors.ustc.edu.cn/brew.git".freezeCORE_TAP_REPO = "git://mirrors.ustc.edu.cn/homebrew-core.git".freeze

 2. 执行安装
  

/usr/bin/ruby ~/brew_install
==> 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 3a99e6464 Merge pull request #4593 from reitermarkus/curl-options
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 4808, done.
remote: Compressing objects: 100% (4601/4601), done.
remote: Total 4808 (delta 60), reused 568 (delta 16), pack-reused 0
Receiving objects: 100% (4808/4808), 3.89 MiB | 107.00 KiB/s, done.
Resolving deltas: 100% (60/60), done.
Tapped 2 commands and 4593 formulae (4,849 files, 12.2MB).
==> Cleaning up /Library/Caches/Homebrew...
==> Migrating /Library/Caches/Homebrew to /Users/jsecode/Library/Caches/Homebrew...
==> Deleting /Library/Caches/Homebrew...
Already up-to-date.
==> Installation successful!

==> Homebrew has enabled anonymous aggregate user behaviour analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics.html

==> Next steps:
- Run `brew help` to get started
- Further documentation:
https://docs.brew.sh

结论:安装成功。

后来在家重新试了下官网方法,又可以安装了。

JSEcodedeMacBook-Pro:nginx shihw$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

==> 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

==> /usr/bin/sudo /bin/mkdir -p /Library/Caches/Homebrew

Password:

==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew

==> /usr/bin/sudo /usr/sbin/chown shihw /Library/Caches/Homebrew

==> Downloading and installing Homebrew...

remote: Counting objects: 62, done.

remote: Compressing objects: 100% (4/4), done.

remote: Total 62 (delta 48), reused 51 (delta 48), pack-reused 10

Unpacking objects: 100% (62/62), done.

From https://github.com/Homebrew/brew

   28fd59672..545eb91c8  master     -> origin/master

HEAD is now at 545eb91c8 Merge pull request #4599 from reitermarkus/download-cache-directory

Updated 1 tap (homebrew/core).

==> Cleaning up /Library/Caches/Homebrew...

==> Migrating /Library/Caches/Homebrew to /Users/jsecode/Library/Caches/Homebrew...

==> Deleting /Library/Caches/Homebrew...

==> New Formulae

gptfdisk                                                                                  pijul

==> Updated Formulae

abcde               cython              emscripten          grpc                ocrmypdf            ripgrep             taskell             vcftools            yarn

awscli              dartsim             erlang@20           hashcat             openshift-cli       rust                teleport            webpack             youtube-dl

cargo-completion    dbus                gammaray            knot-resolver       paket               shibboleth-sp       tmux-xpanes         wireguard-tools

chronograf          dxpy                go-statik           liquigraph          proselint           skaffold            todolist            xml-security-c

==> Installation successful!

==> Homebrew has enabled anonymous aggregate user behaviour analytics.

Read the analytics documentation (and how to opt-out) here:

  https://docs.brew.sh/Analytics.html

==> Next steps:

- Run `brew help` to get started

- Further documentation: 

    https://docs.brew.sh

JSEcodedeMacBook-Pro:nginx shihw$ brew update

Already up-to-date.

JSEcodedeMacBook-Pro:nginx shihw$




 

原文地址:https://www.cnblogs.com/myibm/p/9414587.html