当前位置: > > > 解决macOS系统升级后brew命令报错问题( in `initialize‘: Version value must be a string)

解决macOS系统升级后brew命令报错问题( in `initialize‘: Version value must be a string)

1,问题描述

最近想在 mac 电脑上通过 brew 命令安装个 Nginx 服务,但执行后报如下错误:
Traceback (most recent call last):
11: from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `<main>'
10: from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `require_relative'
9: from /usr/local/Homebrew/Library/Homebrew/global.rb:37:in `<top (required)>'
8: from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
7: from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
6: from /usr/local/Homebrew/Library/Homebrew/os.rb:3:in `<top (required)>'
5: from /usr/local/Homebrew/Library/Homebrew/os.rb:21:in `<module:OS>'
4: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:58:in `prerelease?'
3: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:24:in `version'
2: from /usr/local/Homebrew/Library/Homebrew/os/mac.rb:24:in `new'
1: from /usr/local/Homebrew/Library/Homebrew/os/mac/version.rb:26:in `initialize'
/usr/local/Homebrew/Library/Homebrew/version.rb:368:in `initialize': Version value must be a string; got a NilClass () (TypeError)

2,问题解决

(1)这是因为 Mac 在升级后,之前旧版本的 Homebrew 在新系统不适配。我们直接执行如下命令更新到最新版本的 Homebrew 就可以了:
升级的期间可能会要求输入 github 的邮箱账号和密码,注意:
  • 用户名这里输入的是邮箱账号,不是用户名。
  • 密码部分由于 GitHub 认证策略的改变,现在要输入 tokentoken 获取方式可以参考我写的另一篇文章(点击查看
brew update-reset

(2)更新后执行如下命令查看版本:
brew --version
评论0