自制权限。 / usr / local / sbin不可写

时间:2017-10-10 15:40:29

标签: permissions homebrew symlink

我正在使用OSX 10.12,最近我遇到了一个奇怪的问题。如果我使用Homebrew安装包,则无法链接包,因为权限不正确。运行brew doctor后,我收到以下消息:

Warning: The following directories are not writable:
/usr/local/sbin

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

You should change the ownership and permissions of these directories.
back to your user account.
sudo chown -R $(whoami) /usr/local/sbin

运行了很多不同的权限命令,我在网上找到了我仍在努力解决这个问题。我尝试过(至少)以下命令

sudo chown -R $(whoami) /usr/local
sudo chown -R $(whoami) /usr/local/sbin
sudo chown -R "$USER":admin /usr/local
sudo chown -R "$USER":admin /Library/Caches/Homebrew

非使用过的突击队员在哪里工作。我在每个权限命令后尝试brew docter但似乎没有任何效果。然后我认为应该在usr / local目录中查看使用ls -la的权限。我注意到sbin文件夹是符号链接的。有关usr / local文件夹中的权限,请参阅下面的列表。不确定这是好还是不好?这可能是我的问题的原因,我怎么能解决这个问题?

drwxrwxr-x   16 myusername  staff   544 Oct 10 16:10 .
drwxr-xr-x@  10 root            wheel   340 Mar 28  2017 ..
drwxrwxr-x    2 myusername  staff    68 Oct 10 16:10 Caskroom
drwxr-xr-x   48 myusername  staff  1632 Oct 10 16:47 Cellar
drwxr-xr-x    2 myusername  staff    68 Dec  8  2016 Frameworks
drwxr-xr-x   17 myusername  staff   578 Oct 10 15:20 Homebrew
drwxr-xr-x  198 myusername  staff  6732 Oct 10 16:48 bin
drwxr-xr-x   18 myusername  staff   612 Oct 10 16:48 etc
drwxr-xr-x   65 myusername  staff  2210 Oct 10 16:48 include
drwxr-xr-x  244 myusername  staff  8296 Oct 10 16:48 lib
drwxr-xr-x    3 myusername  staff   102 Dec 12  2014 man
drwxr-xr-x   57 myusername  staff  1938 Oct 10 16:51 opt
drwxr-xr-x    3 myusername  staff   102 Feb 14  2017 remotedesktop
lrwxr-xr-x    1 myusername  staff     9 Jun  9  2013 sbin -> /usr/sbin
drwxr-xr-x   18 myusername  staff   612 Oct 10 16:48 share
drwxr-xr-x   10 myusername  staff   340 Oct 10 15:28 var

这是brew --config命令

的输出
HOMEBREW_VERSION: 1.3.5
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 91ab116ace7f4f97d3440190463c93be9ec6d675
Last commit: 2 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: a57a3704b4e7a8dcb311cf2309d485ad93d4977d
Core tap last commit: 4 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: octa-core 64-bit ivybridge
Homebrew Ruby: 2.3.3 =>         /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby
Clang: 9.0 build 900
Git: 2.13.5 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /usr/bin/ruby =>     /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
Java: N/A
macOS: 10.12.6-x86_64
Xcode: 9.0
CLT: 9.0.0.0.1.1504363082
X11: N/A

这是符号链接的sbin文件夹的权限

drwxr-xr-x   246 root            wheel   8364 Aug  4 02:08 sbin

2 个答案:

答案 0 :(得分:1)

跑步brew doctor应该告诉你:

  

警告:以下目录不存在:   / usr / local / sbin

只需运行:

sudo mkdir -p /usr/local/sbin

和:

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

答案 1 :(得分:0)

我在 Mac OS Big Sur (11.5.1) 上遇到了这个错误。我运行以下命令来修复它:

undefined