mac下安装 autojump

本文讲述了作者在遇到brew更新和安装autojump过程中遇到的网络限制、源问题,最终通过解决git SSL问题和清理缓存解决了一系列技术难题的过程。

一、解决brew 问题

  之前我的brew命令是好使的,后来是,每次安装东西,都找不到包,提示http 指向的包不存在,我通过网页确实是打不开,我也不知道咋办,一直没管,我想,可能需要换个 brew 源吧,然后最近我想安装 autojump,实现目录的直接跳转,报了个新错,我想试图解决一下,不然也太揪心了,错误如下:
在这里插入图片描述
文字版:

(base) ➜  ~ brew install autojump
Traceback (most recent call last):
	9: from /usr/local/Homebrew/Library/Homebrew/brew.rb:29:in `<main>'
	8: from /usr/local/Homebrew/Library/Homebrew/brew.rb:29:in `require_relative'
	7: from /usr/local/Homebrew/Library/Homebrew/global.rb:4:in `<top (required)>'
	6: from /usr/local/Homebrew/Library/Homebrew/global.rb:4:in `require_relative'
	5: from /usr/local/Homebrew/Library/Homebrew/startup.rb:10:in `<top (required)>'
	4: from /usr/local/Homebrew/Library/Homebrew/startup.rb:10:in `require_relative'
	3: from /usr/local/Homebrew/Library/Homebrew/startup/sorbet.rb:9:in `<top (required)>'
	2: from /usr/local/Homebrew/Library/Homebrew/startup/sorbet.rb:9:in `require'
	1: from /usr/local/Homebrew/Library/Homebrew/standalone/sorbet.rb:11:in `<top (required)>'
/usr/local/Homebrew/Library/Homebrew/standalone/sorbet.rb:11:in `require': cannot load such file -- sorbet-runtime-stub (LoadError)
Error:
  homebrew-core is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
This command may take a few minutes to run due to the large size of the repository.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
Traceback (most recent call last):
	9: from /usr/local/Homebrew/Library/Homebrew/brew.rb:29:in `<main>'
	8: from /usr/local/Homebrew/Library/Homebrew/brew.rb:29:in `require_relative'
	7: from /usr/local/Homebrew/Library/Homebrew/global.rb:4:in `<top (required)>'
	6: from /usr/local/Homebrew/Library/Homebrew/global.rb:4:in `require_relative'
	5: from /usr/local/Homebrew/Library/Homebrew/startup.rb:10:in `<top (required)>'
	4: from /usr/local/Homebrew/Library/Homebrew/startup.rb:10:in `require_relative'
	3: from /usr/local/Homebrew/Library/Homebrew/startup/sorbet.rb:9:in `<top (required)>'
	2: from /usr/local/Homebrew/Library/Homebrew/startup/sorbet.rb:9:in `require'
	1: from /usr/local/Homebrew/Library/Homebrew/standalone/sorbet.rb:11:in `<top (required)>'
/usr/local/Homebrew/Library/Homebrew/standalone/sorbet.rb:11:in `require': cannot load such file -- sorbet-runtime-stub (LoadError)

我就按照错误提示,先执行命令

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

成功了,然后我再执行 brew update 仍然报错
在这里插入图片描述
我就直接根据提示

cd /usr/local/Homebrew
git reset --hard origin/master

倒是可以执行 brew update 了,但是下载不了的东西,和我以前一样

(base) ➜  Homebrew git:(stable) ✗ brew update
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:0cb1cc7af109437fe0e020c9f3b7b95c3c709b140bde9f991ad2c1433496dd42
-=O=-                          #           #              #              #
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to pkg-containers.githubusercontent.com:443
==> Downloading https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.8/portable-ruby-2.6.8.yosemite.bottle.tar.gz
##O=- #      #
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
Error: Failed to download ruby from the following locations:
  - https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:0cb1cc7af109437fe0e020c9f3b7b95c3c709b140bde9f991ad2c1433496dd42
  - https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.8/portable-ruby-2.6.8.yosemite.bottle.tar.gz

Do not file an issue on GitHub about this; you will need to figure out for
yourself what issue with your internet connection restricts your access to
GitHub (used for Homebrew updates and binary packages).
Error: Failed to upgrade Homebrew Portable Ruby!
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:0cb1cc7af109437fe0e020c9f3b7b95c3c709b140bde9f991ad2c1433496dd42
-=O=-      #        #          #           #
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to pkg-containers.githubusercontent.com:443
==> Downloading https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.8/portable-ruby-2.6.8.yosemite.bottle.tar.gz
##O=- #      #
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
Error: Failed to download ruby from the following locations:
  - https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:0cb1cc7af109437fe0e020c9f3b7b95c3c709b140bde9f991ad2c1433496dd42
  - https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.8/portable-ruby-2.6.8.yosemite.bottle.tar.gz

Do not file an issue on GitHub about this; you will need to figure out for
yourself what issue with your internet connection restricts your access to
GitHub (used for Homebrew updates and binary packages).
Error: Failed to upgrade Homebrew Portable Ruby!

看样子像是我 git 的问题,但是我 git 可以用啊,不管了,我要重装了

(base) ➜  ~ ll /usr/local/bin/brew
lrwxr-xr-x  1 songbw  admin  28 11 19  2019 /usr/local/bin/brew -> /usr/local/Homebrew/bin/brew

这个是我以前的,然后我决定重装

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”

发现还是报和上面一样的错误

==> 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 /usr/sbin/chown -R songbw:admin /usr/local/Homebrew
==> Downloading and installing Homebrew...
remote: Enumerating objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 1
Unpacking objects: 100% (1/1), done.
From https://github.com/Homebrew/brew
 * [new branch]          fxcoudert-patch-1 -> origin/fxcoudert-patch-1
HEAD is now at 1aa0897dc Merge pull request #12863 from Homebrew/dependabot/bundler/Library/Homebrew/sorbet-0.5.9626
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:0cb1cc7af109437fe0e020c9f3b7b95c3c709b140bde9f991ad2c1433496dd42
-=O=- #      #        #          #
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to pkg-containers.githubusercontent.com:443
==> Downloading https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.8/portable-ruby-2.6.8.yosemite.bottle.tar.gz
#=O#-   #       #
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
Error: Failed to download ruby from the following locations:
  - https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:0cb1cc7af109437fe0e020c9f3b7b95c3c709b140bde9f991ad2c1433496dd42
  - https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.8/portable-ruby-2.6.8.yosemite.bottle.tar.gz

Do not file an issue on GitHub about this; you will need to figure out for
yourself what issue with your internet connection restricts your access to
GitHub (used for Homebrew updates and binary packages).
Error: Failed to upgrade Homebrew Portable Ruby!
To restore the stashed changes to /usr/local/Homebrew, run:
  cd /usr/local/Homebrew && git stash pop
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:0cb1cc7af109437fe0e020c9f3b7b95c3c709b140bde9f991ad2c1433496dd42
-=O=-             #         #            #             #
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to pkg-containers.githubusercontent.com:443
==> Downloading https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.8/portable-ruby-2.6.8.yosemite.bottle.tar.gz
-=O=#     #       #         #
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
Error: Failed to download ruby from the following locations:
  - https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:0cb1cc7af109437fe0e020c9f3b7b95c3c709b140bde9f991ad2c1433496dd42
  - https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.8/portable-ruby-2.6.8.yosemite.bottle.tar.gz

Do not file an issue on GitHub about this; you will need to figure out for
yourself what issue with your internet connection restricts your access to
GitHub (used for Homebrew updates and binary packages).
Error: Failed to upgrade Homebrew Portable Ruby!
Failed during: /usr/local/bin/brew update --force --quiet

  我这才意识到,可能是公司网络的问题,给限制了,因为家离公司近,吃完饭,背着电脑就回家了,我再次执行 brew update ,完全 ok,只是到最后要用 git 访问个东西,报错了,连接不上,说端口访问不了,因为我之前 git 配置过科学上网,软件忘记打开了,这让我明白两点:

  • 确实是公司网络做了限制
  • 虽然可以科学上网,但是只有通过 git 的可以,比如,在 brew update 的时候,需要下载的 rubby 包就下载不了

  搞了半天,原来是公司网络的问题,人生啊

二、autojump 的安装

brew install autojump

  这一步真的是担心坏了,感觉它把我 mac 上所有的软件全都安装了一遍,主要担心我的有些环境会不好使,经历了好久好久,终于安装好了,根据提示我需要把如下代码添加到 zshrc 中

[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh

发现使用 vim 时报错,干脆把 .vimrc 中调用的那一行注释掉,好了,接着执行 source ~/.zshrc 又报错了

compinit:503: no such file or directory: /usr/local/share/zsh/site-functions/_brew_cask

稍加 google 了下,执行

brew cleanup

这才好了,autojump 也可以用了,虽然 autojump 的用法还不是很熟悉

参考文章:
[1] 解决 compinit:503 问题
[2] 还了解了下git stash

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值