Mac OS - 由于权限问题

时间:2018-01-16 04:04:38

标签: mongodb macos permissions homebrew

我按照official guide安装了mongodb,但多次失败。 首先,我尝试使用brew install mongodb

brew --version
Homebrew 1.4.3
brew install mongodb

错误:

Error: Permission denied @ rb_sysopen - /usr/local/var/homebrew/locks/scons.formula.lock

我尝试使用sudo

sudo brew install mongodb

错误:

Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.

我仍在尝试下载二进制文件并通过tar命令解压缩,但它更复杂,我遇到了许多其他问题。所以我希望首先解决这个问题......有什么想法吗?非常感谢。

2 个答案:

答案 0 :(得分:5)

sudo chown -R $USER:admin /usr/local

<强>更新

虽然以上解决了你的问题,但还有更好的方法。

# allow admins to manage homebrew's local install directory
chgrp -R admin /usr/local
chmod -R g+w /usr/local

# allow admins to homebrew's local cache of formulae and source files
chgrp -R admin /Library/Caches/Homebrew
chmod -R g+w /Library/Caches/Homebrew

# if you are using cask then allow admins to manager cask install too
chgrp -R admin /opt/homebrew-cask
chmod -R g+w /opt/homebrew-cask

来源:https://gist.github.com/jaibeee/9a4ea6aa9d428bc77925

答案 1 :(得分:1)

我因权限问题陷入了困境。我最终卸载并重新安装了Homebrew,它对我有用。参考:https://github.com/Homebrew/install