【问题标题】:Homebrew won't brew any moreHomebrew 不会再酿造了
【发布时间】:2016-04-26 17:03:15
【问题描述】:

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

/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 等也会出现同样的错误。

任何想法,可能有什么问题?

【问题讨论】:

  • 你能用more /usr/local/Library/Homebrew/config.rb编辑你的问题吗?

标签: macos homebrew osx-elcapitan


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    有点脏,但我刚刚卸载了自制软件并重新安装。警告:这将卸载所有 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)"
    

    【讨论】:

    • 这正是我需要避免的。
    【解决方案3】:

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

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

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

    然后我可以运行:

    brew doctor
    

    其中发现了权限问题。按照说明修复这些权限最终允许我运行:

    brew update
    

    【讨论】:

    • 这可能也是我的问题的原因。以前版本的 Sophos 弄乱了 /usr/local/bin 和 /usr/local/share 中的权限。只是用 sudo chown -R $(whoami) /usr/local/bin 和 .../share 更新权限对我没有帮助。
    • 是的,我的问题也是从 Sophos 开始的。并继续这样做:|
    • 您需要 Sophos 9.4,它仍处于预览状态。
    • 执行上述步骤后,我收到了数百条这样的消息:Error: Failed to import: xxxxyyyzzz undefined method 'desc' for Formulary::Formulae::XxxxYyyZzz:Class 所以我cd ~ 并再次尝试,一切正常!很好的提示,帮助了我。
    【解决方案4】:

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

    试试这个:

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

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

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

    【讨论】:

    • 在我的情况下,不是 OSX 而是 Sophos 搞砸了权限。在 9.4.1 版本中,他们修复了该错误。
    • 这很有趣!我有 Sohpos 9.2.9 并没有引起问题。虽然我的不是家庭版。
    【解决方案5】:

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

    权限问题修复后,运行brew upgrade 修复了该问题。更新操作系统时,这显然不是一个不常见的问题 - 在 official Homebrew Documenation 上阅读它。

    【讨论】:

      猜你喜欢
      • 2018-12-02
      • 2020-05-30
      • 1970-01-01
      • 1970-01-01
      • 2012-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多