Homebrew 不会再酿造了

Homebrew won't brew any more

在装有 El Capitan 的 MacMini 上,我无法再运行 冲泡咖啡了。我收到以下错误:

/usr/local/Library/Homebrew/config.rb:34:in `initialize': no implicit conversion of nil into String (TypeError)
    from /usr/local/Library/Homebrew/config.rb:34:in `new'
    from /usr/local/Library/Homebrew/config.rb:34:in `<top (required)>'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /usr/local/Library/Homebrew/global.rb:18:in `<top (required)>'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /usr/local/Library/brew.rb:10:in `<main>'

/usr/local的权限是正确的。

我没有更改的 config.rb 文件看起来像这样:

def cache
  if ENV["HOMEBREW_CACHE"]
    Pathname.new(ENV["HOMEBREW_CACHE"]).expand_path
  else
    # we do this for historic reasons, however the cache *should* be the same
    # directory whichever user is used and whatever instance of brew is executed
    home_cache = Pathname.new("~/Library/Caches/Homebrew").expand_path
    if home_cache.directory? && home_cache.writable_real?
      home_cache
    else
      Pathname.new("/Library/Caches/Homebrew").extend Module.new {
        def mkpath
          unless exist?
            super
            chmod 0775
          end
        end
      }
    end
  end
end

HOMEBREW_CACHE = cache
undef cache

# Where brews installed via URL are cached
HOMEBREW_CACHE_FORMULA = HOMEBREW_CACHE+"Formula"

unless defined? HOMEBREW_BREW_FILE
  HOMEBREW_BREW_FILE = ENV["HOMEBREW_BREW_FILE"] || which("brew").to_s
end

# Where we link under
HOMEBREW_PREFIX = Pathname.new(ENV["HOMEBREW_PREFIX"])

# Where .git is found
HOMEBREW_REPOSITORY = Pathname.new(ENV["HOMEBREW_REPOSITORY"])

HOMEBREW_LIBRARY = Pathname.new(ENV["HOMEBREW_LIBRARY"])
HOMEBREW_CONTRIB = HOMEBREW_REPOSITORY/"Library/Contributions"

# Where we store built products
HOMEBREW_CELLAR = Pathname.new(ENV["HOMEBREW_CELLAR"])

HOMEBREW_LOGS = Pathname.new(ENV["HOMEBREW_LOGS"] || "~/Library/Logs/Homebrew/").expand_path

HOMEBREW_TEMP = Pathname.new(ENV.fetch("HOMEBREW_TEMP", "/tmp"))

unless defined? HOMEBREW_LIBRARY_PATH
  HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent.join("Homebrew")
end

HOMEBREW_LOAD_PATH = HOMEBREW_LIBRARY_PATH

brew、brew doctor、brew update 等出现同样的错误

有什么想法,有什么问题吗?

我用在 github 上找到的新版本替换了脚本 /usr/local/bin/brew。现在一切都好了。

最新的文件,其中,可以在这里找到:

有点脏,但我刚刚卸载了自制软件并重新安装。警告:这将卸载所有 brew 安装包。

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
$ sudo chown -R $USER /usr/local/
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

我遇到了同样的问题 - 似乎是 brew 更新由于权限问题而无法完成的结果。

首先我将 repo 重置为最新的 head:

cd /usr/local/bin
git reset --hard HEAD

然后我可以运行:

brew doctor

发现权限问题。按照说明修复这些权限最终让我 运行:

brew update

OS X 每次更新都会弄乱权限。

试试这个:

sudo chown -R $(whoami) /usr/local/share/man/man1

sudo chown -R $(whoami) /usr/local/share/man

并确保当前用户(运行 brew)有权访问 /usr/local

对我有用的是 运行 brew upgrade(不是 brew update)。您可能会遇到其他一些答案中提到的一些权限问题。它会建议一些命令来解决这个问题。

权限问题解决后,运行宁brew upgrade解决了这个问题。更新 OS 时,这显然不是一个不常见的问题 - 在 official Homebrew Documenation.

上阅读相关内容