mac brew安装失败大总结

2020-06-29  本文已影响0人  沉默羔羊121

mac 安装 brew Homebrew
brew 全称Homebrew 是Mac OSX上的软件包管理工具
Homebrew 安装和卸载工具 只用一行命令就能完成
官方地址

mac 自带ruby:

bogon:~ macbook$ ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
bogon:~ macbook$ 

安装homebrew:
执行命令:

bogon:~ macbook$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
bogon:~ macbook$

或执行命令:

bogon:~ macbook$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" 
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
bogon:~ macbook$ 

均出现错误:
curl: (7) Failed to connect to ...... port 443: Connection refused

解决方法:

大多都是重新安装 xcode-select.
但Mac最新场景下安装Xcode时已经没有Command Line了,需要单独安装。根据提示在使用命令xcode-select --install 安装时最后结果是不能安装该软件。

解决方式

Developer Apple上手动下载对应的Command Line Tools 安装即可。

https://developer.apple.com/download/more/

下载

需要用AppleID登陆,登陆后,在左边的搜索框中搜索Command Line Tools 然后回车。


image.png

将其中适合你电脑版本的那个下载下来安装好即可。

安装 Command Line Tools

image.png

执行xcode-select --install提示已经安装了

localhost:~ macbook$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
localhost:~ macbook$ 

继续执行安装homebrew命令:

bogon:~ macbook$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
bogon:~ macbook$

看来还是不行,这个方法在网络有问题时会报如题这个错误。(也许被限制访问里了)
这个时候直接将文件brew_install.rb下载,然后控制台运行ruby brew_install.rb命令即可。此文件下载地址:
链接:https://pan.baidu.com/s/1rVh8bY73NLc77cQYN_2HoQ 密码:n3si
或:链接: https://pan.baidu.com/s/1IEyrskk4IpA4Xl2dakjCFA 提取码: 2c21

查看下载文件 :brew_install.rb

localhost:Downloads macbook$ pwd
/Users/macbook/Downloads
localhost:Downloads macbook$ ls brew*
brew_install.rb
localhost:Downloads macbook$ 

本地安装brew

localhost:Downloads macbook$ ruby brew_install.rb 
==> 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
==> The following new directories will be created:
/usr/local/bin

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir -p /usr/local/bin
Password:
mkdir: /usr/local/bin: Not a directory
Failed during: /usr/bin/sudo /bin/mkdir -p /usr/local/bin
localhost:Downloads macbook$ 

localhost:Downloads macbook$ cd /usr/local/
localhost:local macbook$ sudo mv bin bin_bak
localhost:local macbook$ ls
Caskroom    Homebrew    include     sbin
Cellar      bin_bak     lib     share
Frameworks  etc     opt     var
localhost:local macbook$ sudo mkdir -p -m 775 /usr/local/bin
localhost:local macbook$ 
localhost:local macbook$ pwd
/usr/local
localhost:local macbook$ cd
localhost:~ macbook$ cd Downloads/
localhost:Downloads macbook$ ruby brew_install.rb 
==> 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
==> The following existing directories will be made group writable:
/usr/local/bin
==> The following existing directories will have their owner set to macbook:
/usr/local/bin
==> The following existing directories will have their group set to admin:
/usr/local/bin

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/bin
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin
==> /usr/bin/sudo /usr/sbin/chown macbook /usr/local/bin
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin
==> /usr/bin/sudo /bin/mkdir -p /Users/macbook/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/macbook/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown macbook /Users/macbook/Library/Caches/Homebrew
==> Downloading and installing Homebrew...
/usr/local/Homebrew/.git: Permission denied
Failed during: git init -q
localhost:Downloads macbook$ 

这里再次出现问题:
/usr/local/Homebrew/.git: Permission denied
Failed during: git init -q

懂点英文的话,可能立刻就知道了:权限不足。
不懂英文也没有关系,查下字典也马上就知道了。

然后,如果我们在安装的命令前面加上‘sudo’是不是就可以了呢?

localhost:Downloads macbook$ sudo ruby brew_install.rb 
Password:
Don't run this as root!
localhost:Downloads macbook$

还是不可以
想别的办法吧,我们还可以给文件夹增加权限:

sudo chgrp -R admin /usr/local 
sudo chmod -R g+w /usr/local

在MAC上安装homebrew进行安装,根据react native 文档步骤进行下去,同样在brew update的时候出现报错:Error: /usr/local must be writable! 错误,文档也给出解决办法(sudo chown -R $(whoami) /usr/local),但是这种方法对于高版本的OS来说,是解决不了的,会报chown: /usr/local: Operation not permitted错误。

https://stackoverflow.com/questions/46459152/cant-chown-usr-local-for-homebrew-in-mac-os-x-10-13-high-sierra

if you are using zsh because you come from bash you might have to change your PATH. you should add export PATH=HOME/bin:/usr/local/bin:$PATH
in .zshrc

在.bash_profile环境中加入:

export PATH=HOME/bin:/usr/local/bin:PATH

localhost:~ macbook$cd

localhost:~ macbook$ pwd
/Users/macbook

localhost:~ macbook$ vi .bash_profile

localhost:~ macbook$ cat .bash_profile 
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
export MAVEN_HOME=/Users/macbook/Desktop/soft/apache-maven-3.6.3
#export MAVEN_HOME=/Users/macbook/Downloads/maven-3.6.3-Jeesit/maven3
export PATH=$MAVEN_HOME/bin:$PATH
export PATH=$HOME/bin:/usr/local/bin:$PATH
localhost:~ macbook$ 

再执行安装

localhost:local macbook$ cd
localhost:~ macbook$ cd Downloads/
localhost:Downloads macbook$ ruby brew_install.rb 
==> 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
==> The following existing directories will be made group writable:
/usr/local/bin
==> The following existing directories will have their owner set to macbook:
/usr/local/bin
==> The following existing directories will have their group set to admin:
/usr/local/bin

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/bin
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin
==> /usr/bin/sudo /usr/sbin/chown macbook /usr/local/bin
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin
==> /usr/bin/sudo /bin/mkdir -p /Users/macbook/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/macbook/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown macbook /Users/macbook/Library/Caches/Homebrew
==> Downloading and installing Homebrew...
/usr/local/Homebrew/.git: Permission denied
Failed during: git init -q
localhost:Downloads macbook$ sudo chgrp -R admin /usr/local
Password:
chgrp: /usr/local: Operation not permitted
localhost:Downloads macbook$ sudo chmod -R g+w /usr/local
chmod: Unable to change file mode on /usr/local: Operation not permitted
localhost:Downloads macbook$ sudo chgrp -R macbook /usr/local
chgrp: macbook: illegal group name
localhost:Downloads macbook$ sudo chgrp -R admin /usr/local
chgrp: /usr/local: Operation not permitted
localhost:Downloads macbook$ 
localhost:Downloads macbook$ sudo chgrp -R admin /usr/local
Password:
chgrp: /usr/local: Operation not permitted
localhost:Downloads macbook$ pwd
/Users/macbook/Downloads
localhost:Downloads macbook$ ruby brew_install.rb 
==> 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
==> The following existing directories will be made writable by user only:
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
==> The following existing directories will have their owner set to macbook:
/usr/local/share/zsh
/usr/local/share/zsh/site-functions

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/share/zsh /usr/local/share/zsh/site-functions
==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
==> /usr/bin/sudo /usr/sbin/chown macbook /usr/local/share/zsh /usr/local/share/zsh/site-functions
==> Downloading and installing Homebrew...
remote: Enumerating objects: 139547, done.
remote: Total 139547 (delta 0), reused 0 (delta 0), pack-reused 139547
Receiving objects: 100% (139547/139547), 34.40 MiB | 70.00 KiB/s, done.
Resolving deltas: 100% (102645/102645), done.
From https://github.com/Homebrew/brew
 * [new branch]      master     -> origin/master
 * [new tag]         0.1        -> 0.1
 * [new tag]         0.2        -> 0.2
 * [new tag]         0.3        -> 0.3
 * [new tag]         0.4        -> 0.4
 * [new tag]         0.5        -> 0.5
 * [new tag]         0.6        -> 0.6
 * [new tag]         0.7        -> 0.7
 * [new tag]         0.7.1      -> 0.7.1
 * [new tag]         0.8        -> 0.8
 * [new tag]         0.8.1      -> 0.8.1
 * [new tag]         0.9        -> 0.9
 * [new tag]         0.9.1      -> 0.9.1
 * [new tag]         0.9.2      -> 0.9.2
 * [new tag]         0.9.3      -> 0.9.3
 * [new tag]         0.9.4      -> 0.9.4
 * [new tag]         0.9.5      -> 0.9.5
 * [new tag]         0.9.8      -> 0.9.8
 * [new tag]         0.9.9      -> 0.9.9
 * [new tag]         1.0.0      -> 1.0.0
 * [new tag]         1.0.1      -> 1.0.1
 * [new tag]         1.0.2      -> 1.0.2
 * [new tag]         1.0.3      -> 1.0.3
 * [new tag]         1.0.4      -> 1.0.4
 * [new tag]         1.0.5      -> 1.0.5
 * [new tag]         1.0.6      -> 1.0.6
 * [new tag]         1.0.7      -> 1.0.7
 * [new tag]         1.0.8      -> 1.0.8
 * [new tag]         1.0.9      -> 1.0.9
 * [new tag]         1.1.0      -> 1.1.0
 * [new tag]         1.1.1      -> 1.1.1
 * [new tag]         1.1.10     -> 1.1.10
 * [new tag]         1.1.11     -> 1.1.11
 * [new tag]         1.1.12     -> 1.1.12
 * [new tag]         1.1.13     -> 1.1.13
 * [new tag]         1.1.2      -> 1.1.2
 * [new tag]         1.1.3      -> 1.1.3
 * [new tag]         1.1.4      -> 1.1.4
 * [new tag]         1.1.5      -> 1.1.5
 * [new tag]         1.1.6      -> 1.1.6
 * [new tag]         1.1.7      -> 1.1.7
 * [new tag]         1.1.8      -> 1.1.8
 * [new tag]         1.1.9      -> 1.1.9
 * [new tag]         1.2.0      -> 1.2.0
 * [new tag]         1.2.1      -> 1.2.1
 * [new tag]         1.2.2      -> 1.2.2
 * [new tag]         1.2.3      -> 1.2.3
 * [new tag]         1.2.4      -> 1.2.4
 * [new tag]         1.2.5      -> 1.2.5
 * [new tag]         1.2.6      -> 1.2.6
 * [new tag]         1.3.0      -> 1.3.0
 * [new tag]         1.3.1      -> 1.3.1
 * [new tag]         1.3.2      -> 1.3.2
 * [new tag]         1.3.3      -> 1.3.3
 * [new tag]         1.3.4      -> 1.3.4
 * [new tag]         1.3.5      -> 1.3.5
 * [new tag]         1.3.6      -> 1.3.6
 * [new tag]         1.3.7      -> 1.3.7
 * [new tag]         1.3.8      -> 1.3.8
 * [new tag]         1.3.9      -> 1.3.9
 * [new tag]         1.4.0      -> 1.4.0
 * [new tag]         1.4.1      -> 1.4.1
 * [new tag]         1.4.2      -> 1.4.2
 * [new tag]         1.4.3      -> 1.4.3
 * [new tag]         1.5.0      -> 1.5.0
 * [new tag]         1.5.1      -> 1.5.1
 * [new tag]         1.5.10     -> 1.5.10
 * [new tag]         1.5.11     -> 1.5.11
 * [new tag]         1.5.12     -> 1.5.12
 * [new tag]         1.5.13     -> 1.5.13
 * [new tag]         1.5.14     -> 1.5.14
 * [new tag]         1.5.2      -> 1.5.2
 * [new tag]         1.5.3      -> 1.5.3
 * [new tag]         1.5.4      -> 1.5.4
 * [new tag]         1.5.5      -> 1.5.5
 * [new tag]         1.5.6      -> 1.5.6
 * [new tag]         1.5.7      -> 1.5.7
 * [new tag]         1.5.8      -> 1.5.8
 * [new tag]         1.5.9      -> 1.5.9
 * [new tag]         1.6.0      -> 1.6.0
 * [new tag]         1.6.1      -> 1.6.1
 * [new tag]         1.6.10     -> 1.6.10
 * [new tag]         1.6.11     -> 1.6.11
 * [new tag]         1.6.12     -> 1.6.12
 * [new tag]         1.6.13     -> 1.6.13
 * [new tag]         1.6.14     -> 1.6.14
 * [new tag]         1.6.15     -> 1.6.15
 * [new tag]         1.6.16     -> 1.6.16
 * [new tag]         1.6.17     -> 1.6.17
 * [new tag]         1.6.2      -> 1.6.2
 * [new tag]         1.6.3      -> 1.6.3
 * [new tag]         1.6.4      -> 1.6.4
 * [new tag]         1.6.5      -> 1.6.5
 * [new tag]         1.6.6      -> 1.6.6
 * [new tag]         1.6.7      -> 1.6.7
 * [new tag]         1.6.8      -> 1.6.8
 * [new tag]         1.6.9      -> 1.6.9
 * [new tag]         1.7.0      -> 1.7.0
 * [new tag]         1.7.1      -> 1.7.1
 * [new tag]         1.7.2      -> 1.7.2
 * [new tag]         1.7.3      -> 1.7.3
 * [new tag]         1.7.4      -> 1.7.4
 * [new tag]         1.7.5      -> 1.7.5
 * [new tag]         1.7.6      -> 1.7.6
 * [new tag]         1.7.7      -> 1.7.7
 * [new tag]         1.8.0      -> 1.8.0
 * [new tag]         1.8.1      -> 1.8.1
 * [new tag]         1.8.2      -> 1.8.2
 * [new tag]         1.8.3      -> 1.8.3
 * [new tag]         1.8.4      -> 1.8.4
 * [new tag]         1.8.5      -> 1.8.5
 * [new tag]         1.8.6      -> 1.8.6
 * [new tag]         1.9.0      -> 1.9.0
 * [new tag]         1.9.1      -> 1.9.1
 * [new tag]         1.9.2      -> 1.9.2
 * [new tag]         1.9.3      -> 1.9.3
 * [new tag]         2.0.0      -> 2.0.0
 * [new tag]         2.0.1      -> 2.0.1
 * [new tag]         2.0.2      -> 2.0.2
 * [new tag]         2.0.3      -> 2.0.3
 * [new tag]         2.0.4      -> 2.0.4
 * [new tag]         2.0.5      -> 2.0.5
 * [new tag]         2.0.6      -> 2.0.6
 * [new tag]         2.1.0      -> 2.1.0
 * [new tag]         2.1.1      -> 2.1.1
 * [new tag]         2.1.10     -> 2.1.10
 * [new tag]         2.1.11     -> 2.1.11
 * [new tag]         2.1.12     -> 2.1.12
 * [new tag]         2.1.13     -> 2.1.13
 * [new tag]         2.1.14     -> 2.1.14
 * [new tag]         2.1.15     -> 2.1.15
 * [new tag]         2.1.16     -> 2.1.16
 * [new tag]         2.1.2      -> 2.1.2
 * [new tag]         2.1.3      -> 2.1.3
 * [new tag]         2.1.4      -> 2.1.4
 * [new tag]         2.1.5      -> 2.1.5
 * [new tag]         2.1.6      -> 2.1.6
 * [new tag]         2.1.7      -> 2.1.7
 * [new tag]         2.1.8      -> 2.1.8
 * [new tag]         2.1.9      -> 2.1.9
 * [new tag]         2.2.0      -> 2.2.0
 * [new tag]         2.2.1      -> 2.2.1
 * [new tag]         2.2.10     -> 2.2.10
 * [new tag]         2.2.11     -> 2.2.11
 * [new tag]         2.2.12     -> 2.2.12
 * [new tag]         2.2.13     -> 2.2.13
 * [new tag]         2.2.14     -> 2.2.14
 * [new tag]         2.2.15     -> 2.2.15
 * [new tag]         2.2.16     -> 2.2.16
 * [new tag]         2.2.17     -> 2.2.17
 * [new tag]         2.2.2      -> 2.2.2
 * [new tag]         2.2.3      -> 2.2.3
 * [new tag]         2.2.4      -> 2.2.4
 * [new tag]         2.2.5      -> 2.2.5
 * [new tag]         2.2.6      -> 2.2.6
 * [new tag]         2.2.7      -> 2.2.7
 * [new tag]         2.2.8      -> 2.2.8
 * [new tag]         2.2.9      -> 2.2.9
 * [new tag]         2.3.0      -> 2.3.0
 * [new tag]         2.4.0      -> 2.4.0
 * [new tag]         2.4.1      -> 2.4.1
 * [new tag]         2.4.2      -> 2.4.2
HEAD is now at b4cd99c67 Merge pull request #7833 from iMichka/resource-empty
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
==> 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'...
remote: Enumerating objects: 172, done.
remote: Counting objects: 100% (172/172), done.
remote: Compressing objects: 100% (120/120), done.
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
Error: Failure while executing; `git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core` 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
localhost:Downloads macbook$

又出现新的错误啦::::

remote: Compressing objects: 100% (120/120), done.
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
Error: Failure while executing; git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core 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
localhost:Downloads macbook$

虽然出错,但可以 brew -v了。

localhost:Downloads macbook$ brew -v
Homebrew 2.4.2
Homebrew/homebrew-core N/A
localhost:Downloads macbook$

其他操作

sudo mkdir -p /usr/local/Frameworks
sudo chown -R $(whoami) /usr/local/Frameworks
I have OSX High Mojave(版本10.14.6)

错误信息

error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

没办法-网络ping不通

localhost:~ macbook$ ping github.com
PING github.com (52.74.223.119): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
Request timeout for icmp_seq 7
Request timeout for icmp_seq 8
Request timeout for icmp_seq 9
Request timeout for icmp_seq 10

安装结论:科学科研上网吧。想起来刚才,虽然安装过程有错误,刚才brew -v 成功了。所以还是试试安装一下redis:

localhost:~ macbook$ brew -v
Homebrew 2.4.2
Homebrew/homebrew-core (git revision 8661c; last commit 2020-06-29)
localhost:~ macbook$ 

测试一下 $ brew update

localhost:~ macbook$ brew -v
Homebrew 2.4.2
Homebrew/homebrew-core (git revision 8661c; last commit 2020-06-29)
localhost:~ macbook$ brew update
Updated 1 tap (homebrew/core).
==> New Formulae
uptoc
==> Updated Formulae
bagit                      borgmatic                  dpkg
localhost:~ macbook$ 

用brew安装redis

localhost:Downloads macbook$ sudo chown -R $(whoami) $(brew --prefix)/*
localhost:Downloads macbook$ brew install redis
Updating Homebrew...
==> 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` exited with 128.
Error: Failure while executing; `/usr/local/bin/brew tap homebrew/core` exited with 1.
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 173, done.
remote: Counting objects: 100% (173/173), done.
remote: Compressing objects: 100% (121/121), done.
remote: Total 739732 (delta 102), reused 99 (delta 52), pack-reused 739559
Receiving objects: 100% (739732/739732), 298.26 MiB | 282.00 KiB/s, done.
Resolving deltas: 100% (489612/489612), done.
Tapped 2 commands and 5080 formulae (5,352 files, 327MB).
==> Downloading https://homebrew.bintray.com/bottles/openssl%401.1-1.1.1g.mojave
==> Downloading from https://akamai.bintray.com/5c/5c9d113393ff3efc95e5509175305
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/redis-6.0.5.mojave.bottle.t
==> Downloading from https://akamai.bintray.com/fc/fc2ff703029e0dfceff2ecde31730
######################################################################## 100.0%
==> Installing dependencies for redis: openssl@1.1
==> Installing redis dependency: openssl@1.1
==> Pouring openssl@1.1-1.1.1g.mojave.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 macOS provides LibreSSL.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> /Users/macbook/.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"

==> Summary
🍺  /usr/local/Cellar/openssl@1.1/1.1.1g: 8,059 files, 18MB
==> Installing redis
==> Pouring redis-6.0.5.mojave.bottle.tar.gz
==> Caveats
To have launchd start redis now and restart at login:
  brew services start redis
Or, if you don't want/need a background service you can just run:
  redis-server /usr/local/etc/redis.conf
==> Summary
🍺  /usr/local/Cellar/redis/6.0.5: 13 files, 3.8MB
==> Caveats
==> openssl@1.1
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 macOS provides LibreSSL.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> /Users/macbook/.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"

==> redis
To have launchd start redis now and restart at login:
  brew services start redis
Or, if you don't want/need a background service you can just run:
  redis-server /usr/local/etc/redis.conf
localhost:Downloads macbook$ 

启动redis-server

localhost:~ macbook$ 
localhost:~ macbook$ redis-server
4977:C 29 Jun 2020 16:26:18.154 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
4977:C 29 Jun 2020 16:26:18.154 # Redis version=6.0.5, bits=64, commit=00000000, modified=0, pid=4977, just started
4977:C 29 Jun 2020 16:26:18.154 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
4977:M 29 Jun 2020 16:26:18.155 * Increased maximum number of open files to 10032 (it was originally set to 256).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 6.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 4977
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

4977:M 29 Jun 2020 16:26:18.156 # Server initialized
4977:M 29 Jun 2020 16:26:18.156 * Ready to accept connections


用redis-cli 连接redis-server

Last login: Mon Jun 29 16:34:17 on ttys000
localhost:~ macbook$ redis-cli 
127.0.0.1:6379> keys *
(empty array)
127.0.0.1:6379> 

据说还有以下方法:Homebrew换源 (我是没时间折腾了 放弃了,还有方法就是vpn,但那个仅属于科学上网不合法)

https://www.jianshu.com/p/0cea9650918d

  1. 替换brew.git:
$ cd "$(brew --repo)"
中科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
清华:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
  1. 替换homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
>中科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
>清华:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
  1. 替换homebrew-bottles:
>>中科大:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
>>清华:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

收藏brew命令

brew list 列出已安装的软件
brew update 更新brew

brew home 用浏览器打开brew的官方网站

brew info 显示软件信息

brew deps 显示包依赖

查询redis安装位置

localhost:~ macbook$ sudo find / -name "redis"
Password:
/usr/local/var/homebrew/linked/redis
/usr/local/var/db/redis
/usr/local/opt/redis
/usr/local/Cellar/redis
/usr/local/Cellar/redis/6.0.5/.bottle/var/db/redis

方法2

localhost:~ macbook$ brew list
openssl@1.1 redis
localhost:~ macbook$ brew --prefix redis
/usr/local/opt/redis
localhost:~ macbook$

查询homebrew安装地址

localhost:~ macbook$ brew config|grep HOMEBREW
HOMEBREW_VERSION: 2.4.2
HOMEBREW_PREFIX: /usr/local
HOMEBREW_MAKE_JOBS: 8
localhost:~ macbook$ 

卸载

下面附上卸载的方法
虽然我不知道你为什么要卸载它,但是如果你执意要这么做的话,可以参考下面的方法:

$ cd `brew --prefix`
$ rm -rf Cellar
$ brew prune
$ rm `git ls-files`
$ rm -r Library/Homebrew Library/Aliases Library/Formula 
Library/Contributions
$ rm -rf .git
$ rm -rf ~/Library/Caches/Homebrew

回顾最初的命令

先卸载已安装的homebrew,命令如下:

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

然后重新安装:

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

附资源地址URLs:

https://redis.io/

https://brew.sh/index_zh-cn
https://raw.githubusercontent.com/Homebrew/install/master/install

附图1:

image.png

附图2

image.png
上一篇 下一篇

猜你喜欢

热点阅读