使`/ usr / local`中的文件可写为自制


35

我一直在努力使自制软件正常工作,但似乎内部所有内容/usr/local均不可写,并且所有内容都掉落了。

它一直告诉我要递归进行chown /usr/local,而我尝试过。操作被拒绝,所以我很udo嘘。它似乎有效,但是我听到那令人毛骨悚然的沉默在Unix中被认为是礼貌的。不幸的是,任何随后的尝试都会brew update遇到同样的错误。

我重新运行命令,-v看起来里面的任何东西都不允许进行该操作。

尽管答案可能是“学习UNIX”,但我只是想遵守Ruby教程的一些工作要求,所以这比我目前所处的位置要高一些。

brew doctor

Warning: /usr/local/Frameworks isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/Frameworks
Warning: /usr/local/Cellar isn't writable.
You should `chown` /usr/local/Cellar
Warning: /usr/local/etc isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/etc
Warning: /usr/local/include isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/include
Warning: /usr/local/lib isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/lib
Warning: /usr/local/lib/pkgconfig isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/lib/pkgconfig
Warning: /usr/local/opt isn't writable.
You should `chown` /usr/local/opt
Warning: /usr/local/share isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/share
Warning: Some directories in /usr/local/share/man aren't writable.
This can happen if you "sudo make install" software that isn't managed
by Homebrew. If a brew tries to add locale information to one of these
directories, then the install will fail during the link step.
You should probably `chown` them:

    /usr/local/share/man
    /usr/local/share/man/man1
    /usr/local/share/man/man3
    /usr/local/share/man/man5
    /usr/local/share/man/man7
    /usr/local/share/man/man8
Warning: /usr/local/var isn't writable.

This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/var

brew doctor告诉你什么有用吗?将输出发布到此处。
伊恩C.

@IanC。这是一长串列出所有与啤酒相关的不可写内容的列表。是否有stackexchange pastebin实用程序?有很多
Tigt

好吧,这很奇怪。现在比以前少了很多。
Tigt

仅供参考:我刚跑完brew update,发现“ Homebrew不再需要拥有/ usr / local的所有权。” 有关此问题的更多信息。显然要达到这一点,您仍然需要临时更新/ usr / local的权限:)
acobster

Answers:


26

应该通过以下方式解决更改该目录上的权限的问题:

$ cd /usr/local
$ sudo chown -R <your-username>:<your-group-name> *

如果您不知道您的小组,只需输入id -g


重要的是-R使其递归。而且您可能必须chown使用sudo。对于用户组,我通常用staff在OS X
nwinkler

有趣。为什么使用组与仅使用用户有何不同?
Tigt

4
为什么/ usr / local由您的用户拥有是正确的?我认为这存在安全隐患,因为还有许多其他程序使用/ usr / local并可能被静默接管。酿造真的需要如此激烈的东西吗?
dfrankow '16

1
我认为这很危险,因为它选择了“ staff”组,这意味着操作系统上的每个用户都可以更改/ usr /的内容。您可能应该切换到“管理员”。
Indolering '17

1
@dfrankow是的,这是自制的错误。他们甚至不认为如果同一台计算机上有两个用户,会发生什么。
poige

22

您必须使用sudo以提升的特权运行命令,如下所示:

sudo chown -R `whoami` /usr/local

是的 “行动被拒绝了,所以我很自豪。”
Tigt

1
对于sudo chown -R (whoami) /usr/local
鱼壳

10

昨天我面临这个问题和MacOS 10.13.4,我试图sudo chgrp -R admin /usr/localsudo chown -R <your-username>:<your-group-name> /usr/local这让Operation not permitted即使使用错误sudo

因此,我尝试仅chgrpHomebrew相关文件夹设置为admin(我的用户在admin组中,取决于您所运行的用户,您可能会更改为其他组),并admin使用这些命令授予组对这些文件夹的写访问权限

sudo chgrp -R admin /usr/local/Homebrew/
sudo chmod -R g+w /usr/local/Homebrew/
sudo chgrp -R admin /usr/local/var/homebrew/
sudo chmod -R g+w /usr/local/var/homebrew/

运行这些命令后,我可以没有任何问题地安装新软件包。如果您再次遇到任何权限问题,请尝试通过使用您遇到权限问题的文件夹名称替换文件夹名称来运行前两个命令。

希望这对使用macOS 10.13的其他用户有所帮助。

注意:即使更改所有者/usr/local或更改组/usr/local的权限并为您的组授予访问权限也可以,但是在修改其他不相关的文件夹时也绝对不要这样做。修改所需的文件夹更加安全。


这对我来说真的很好!<3感谢
DariusV

这应该被选为正确答案!谢谢你的帮助!
伊妮

2

要解决目录上的权限问题,我们可以执行以下命令:

brew prune

1

它为我工作。

sudo chgrp -R admin /usr/local
sudo chmod -R g+w /usr/local

0

Reza在这个问题上的答案对我有用:

sudo chown -R $(whoami) /usr/local/*

您不能更改/ usr / local本身的权限,但是可以更改下面文件夹的正确权限。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.