Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Homebrew permissions. /usr/local/sbin not writable

I'm using OSX 10.12 and I recently encountered a weird problem. If i install a package with Homebrew the package can not be linked because the permissions are not correct. After running brew doctor i get the following message:

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

After running a lot of different permission commands i found on the web i'm still struggling with this problem. I tried (at least) the following commands

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

Non of the used commando's where working. I tried brew docter after every permission command but nothing seems to work. Then i thought it should have a look at the permissions using ls -la in the usr/local directory. I noticed that the sbin folder is symlinked. See the list below for my permissions in the usr/local folder. Not sure if this is good or not?? Could this be the reason of my problem and how could i fix this??

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

This is the output of the brew --config command

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

This are the permissions of the sbin folder that is symlinked

drwxr-xr-x   246 root            wheel   8364 Aug  4 02:08 sbin
like image 391
Jasper Rooduijn Avatar asked Oct 10 '17 15:10

Jasper Rooduijn


2 Answers

Running brew doctor should tell you:

Warning: The following directories do not exist: /usr/local/sbin

Just run:

sudo mkdir -p /usr/local/sbin

and:

sudo chown -R $(whoami) /usr/local/sbin
like image 58
Guillaume Bihet Avatar answered Oct 01 '22 14:10

Guillaume Bihet


I experienced this error on Mac OS Big Sur (11.5.1). I run the following to fix it:

sudo chown -R $(whoami) /usr/local/sbin
like image 39
yaach Avatar answered Oct 01 '22 13:10

yaach