ChatGPT解决这个技术问题 Extra ChatGPT

Brew doctor says: "Warning: /usr/local/include isn't writable."

Brew doctor says:

Warning: /usr/local/include isn't writable. This can happen if you "sudo make install" software that isn't managed by Homebrew. If a brew tries to write a header file to this directory, the install will fail during the link step. You should probably chown /usr/local/include

I've tried different commands to solve this but I'm still stuck here.

I'm running homebrew on 10.8.2

I got a similar error for "/usr/local/lib" in Homebrew 0.9.4 that was also resolved with the solution below.

j
jrwren

Take ownership of it and everything in it.

Mac OS High Sierra or newer: (ty to Kirk in the comments below)

$ sudo chown -R $(whoami) $(brew --prefix)/*

Previous versions of macos:

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

Then do another

$ brew doctor

operation not permitted?
Any advantage instead of $ sudo chown -R `whoami` /usr/local/?
@WillemLabu one less process fork? whoami is effective user id and as the man page says is obsolete :) bash is default shell on OSX and somewhere USER is getting set.
I wonder whether changing ownership of /usr/local to a user a clean solution. Wouldn't it be better to add $USER to the 'wheel' group? Or change the group of /usr/local to the admin group?
According to Homebrew in Mac OS High Sierra chown /usr/local doesn't work anymore. Instead use sudo chown -R $(whoami) $(brew --prefix)/*
D
Durul Dalkanat

What worked for me was too

sudo chmod g+w /usr/local
sudo chgrp staff /usr/local

This is the only sane fix, not really sane to take ownership of /usr/local in a multiuser os
Need to get this guy some votes! ;) This worked great.
This is the better solution IMHO
Well, not in High Sierra. "Unable to change file mode on /usr/local: Operation not permitted"
@user980018 I just ran into the same thing - here's the workaround I used
A
Ana Isabel

What worked for me was

$ sudo chown -R yourname:admin /usr/local/bin

H
Husky

The only one that worked for me on El Capitan was:

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

chown: /usr/local: Operation not permitted
@AlxVallejo doing it on /usr/local/bin worked for me
For anyone reading now: if sudo chown -R $(whoami) /usr/local results in an error on Big Sur, try sudo chown -R $(whoami) /usr/local/include
P
Pro

If you are on High Sierra and experiencing this issue, follow the steps below (Note: /usr/local cannot be chown'd in High Sierra):

sudo mkdir /usr/local/include
sudo chown -R $(whoami) $(brew --prefix)/*

Then try linking with brew link. I was experiencing similar issue and none of the solutions above worked for High Sierra. Hope this helps someone.


I tried a lot. Brew doctor told that the dir is missing. Your answer helped me and am able to do the work. Thank you. Mac Users, Please try this.
M
Mogsdad

For High Sierra:

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

Then, try your brew commands.

Issue #3285


Not sure why this was downvoted, if you previously had brew installed and upgraded to High Sierra, reinstalling Homebrew fixes the issue. This is the easiest approach
Ironically that's because the script does exactly what the other answers are suggesting.
This worked for me but first i uninstalled the previous using: ruby -e "$(curl -fsSL raw.githubusercontent.com/Homebrew/install/master/uninstall)"
k
karlingen

You can alias the command to fix this problem in your .bash_profile and run it every time you encounter it:

At the end of the file ~/.bash_profile, add:

alias fix_brew='sudo chown -R $USER /usr/local/'

And now inside your terminal you can run:

$ fix_brew

M
Max

This worked for me on macOS 10.12

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

I had the problem updating homebrew with the following error:

/usr/local is not writable. You should change the ownership
and permissions of /usr/local back to your user account:
  sudo chown -R $(whoami) /usr/local

J
Jonathan James

For some it's going to be:

sudo chown -R JonJames:admin /usr/local/lib

where "lib" is used as opposed to "bin" or "include" or "whatever else"

The Homebrew Warning "should" explain what specifically is not writable and then give you a command syntax for follow, however you will need to use the ":" as opposed to what the Warning mentions which is actually not correct syntax??


The syntax in the Warning is a bit confusing I believe, I emailed the lead contributor for Homebrew to ask if they would change anything about it, awaiting reply, perhaps the Warning's verbiage will change in future brew updates..
thanks! This worked after a fair amount of searching around.
A
Alexander Salas Bastidas

Work for me

$ sudo chown -R $(whoami):admin /usr/local

$ cd /usr/local/Library && git stash && git clean -d -f

M
Matthew

First you need to create the directory:

sudo mkdir /usr/local/include

Second:

sudo chown -R $(whoami) $(brew --prefix)/*

c
cSteusloff

Same error on MacOS 10.13

/usr/local/include and /usr/local/ /usr/lib were not created. I manually created and brew link finally worked.


J
JayRizzo

What Worked for me, while having I have more than 1 user on my computer.

Using terminal:

Running brew doctor Seeing multiple /usr/local/... isn't writable error's

Seeing multiple /usr/local/... isn't writable error's

Disabling Mac's System Integrity Protection: https://apple.stackexchange.com/a/208481/55628

Run the following

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

brew doctor && brew upgrade && brew doctor

Running Macbook Pro OSX High Sierra (version 10.13.3.)

EDIT 1:

FYI - Please be Advised this causes an issue with running MySQL on your MAC. To be able to start my local server, I had to run:

sudo chown -R mysql:mysql /usr/local/mysql/data

After you run this you can start your local MySQL Server.


Excellent! Thank you!
w
waldencoder

You need to create /usr/local/include and /usr/local/lib if they don't exists:

$ sudo mkdir -p /usr/local/include
$ sudo chown -R $USER:admin /usr/local/include

P
Paul Roub
sudo mkdir -p /usr/local/include /usr/local/lib /usr/local/sbin

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

This will create all required directories and give it the correct ownership.

After running these commands check with: brew doctor

This works for Mojave.


a
add-semi-colons

You need to get control of entire /usr/local to do that you need to do a recursive chown under /usr/local

sudo chown -R YOUR_USERNAME:admin /usr/local/


a
adamkski

I just want to echo sam9046's modest comment as an alternative and potentially much easier solution that worked in my case: uninstall and install homebrew again from scratch. No sudo commands required.

You can also browse/modify the uninstall script from that link above if you need to ensure it won't affect your previously installed packages. In my case this was just my home machine so I just started over.


T
Tarun

I have had this happen in my organization after all our users were bound to active directory (effectively changing the UID from 50x to ######).

Now it is simply a case of changing the ownership of all files where were owned by x to y.

Where 501 is my old numeric user id which is still associated with all the homebrew files.

The old user id can be found using ll /usr/local/Cellar

Now update the ownership sudo find /usr/local -user 501 -exec chown -h $USER {} \;

This way we avoid changing the ownership on files which are not controlled by homebrew or belong to some other system user.


Y
Yusuf

Go into the /bin directory and type:

chown -R $(whoami):admin /usr/local/bin


关注公众号,不定期副业成功案例分享
Follow WeChat

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now