安装Homebrew时的权限错误

时间:2014-10-23 00:30:24

标签: permissions osx-mavericks homebrew

我正在尝试在运行OS X 10.9.2的旧版,不太好维护的盒子上安装Homebrew。当我使用Homebrew网站上的自动安装脚本时:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

我收到一系列权限错误:

==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 207213, done.
remote: Compressing objects: 100% (55712/55712), done.
remote: Total 207213 (delta 150324), reused 207201 (delta 150315)
Receiving objects: 100% (207213/207213), 43.70 MiB | 5.35 MiB/s, done.
Resolving deltas: 100% (150324/150324), done.
From https://github.com/Homebrew/homebrew
 * [new branch]      master     -> origin/master
error: unable to unlink old 'Library/Homebrew/extend/ENV/shared.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/extend/ENV/std.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/extend/ENV/super.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/hooks/bottles.rb' (Permission denied)
error: unable to create file Library/Homebrew/language/go.rb (Permission denied)
error: unable to create file Library/Homebrew/language/haskell.rb (Permission denied)
error: unable to unlink old 'Library/Homebrew/language/python.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/requirements/fortran_dependency.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/requirements/language_module_dependency.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/requirements/ld64_dependency.rb' (Permission denied)
error: unable to create file Library/Homebrew/requirements/maximum_macos_requirement.rb (Permission denied)
error: unable to unlink old 'Library/Homebrew/requirements/minimum_macos_requirement.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/requirements/mpi_dependency.rb' (Permission denied)
error: unable to create file Library/Homebrew/requirements/osxfuse_dependency.rb (Permission denied)
error: unable to unlink old 'Library/Homebrew/requirements/python_dependency.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/requirements/x11_dependency.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/utils/inreplace.rb' (Permission denied)
error: unable to unlink old 'Library/Homebrew/utils/json.rb' (Permission denied)
error: unable to create file Library/Homebrew/utils/popen.rb (Permission denied)
error: unable to unlink old 'Library/Homebrew/vendor/okjson.rb' (Permission denied)
fatal: Could not reset index file to revision 'origin/master'.
Failed during: git reset --hard origin/master

为什么会出现这些问题?据我所知(基于上面代码片段的第一行),Homebrew的安装脚本在该目录上执行chmod以赋予其适当的权限。

如何解决此问题?

2 个答案:

答案 0 :(得分:5)

您需要重置/usr/local

的权限
brew update
brew upgrade
brew cleanup
brew install node
brew link --overwrite node
sudo chown -R `whoami` /usr/local

在某些情况下,brew update失败并出现类似错误。在这种情况下,首先使用chown重置您的权限,然后运行brew update和其他命令。

答案 1 :(得分:2)

在尝试使用旧的,半卸载的brew的机器上安装/更新brew时,我遇到了同样的错误。我首先关注uninstall command

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

然后发出安装命令

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"