在我使用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等发生同样的错误。
任何想法,可能出现什么问题?
答案 0 :(得分:54)
我有同样的问题 - 似乎是由于权限问题无法完成的brew更新的结果。
首先我将回购重置为最新的头:
cd /usr/local/bin
git reset --hard HEAD
然后我可以跑:
brew doctor
找到权限问题。根据说明修复这些权限最终允许我运行:
brew update
答案 1 :(得分:5)
OS X会在每次更新时都会破坏权限。
试试这个:
sudo chown -R $(whoami) /usr/local/share/man/man1
和
sudo chown -R $(whoami) /usr/local/share/man
并确保当前用户(正在运行brew
的用户)有权访问/usr/local
。
答案 2 :(得分:2)
我将脚本/ usr / local / bin / brew替换为我在github上找到的新版本。现在一切都很好了。
最新文件,可在此处找到: https://github.com/Homebrew/homebrew/blob/master/bin/brew
答案 3 :(得分:0)
有点脏,但我刚刚卸载自制软件并重新安装。警告:这将卸载所有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)"
答案 4 :(得分:0)
我将脚本/ usr / local / bin / brew替换为我在github上找到的新版本。现在一切都很好。
最新文件,可在此处找到:https://github.com/Homebrew/homebrew/blob/master/bin/brew
答案 5 :(得分:0)
对我有用的是运行brew upgrade
(而不是brew update
)。您可能会遇到其他一些答案中提到的某些权限问题。它将建议一些命令来解决此问题。
解决权限问题后,运行brew upgrade
解决了该问题。在更新操作系统时,这显然不是一个罕见的问题-在official Homebrew Documenation上了解它。