Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Homebrew Permissions Denied Issues Solution

Installing and fixing node.JS


brew install node

$ brew install node
==> Downloading http://nodejs.org/dist/v0.10.4/node-v0.10.4.tar.gz
Already downloaded: /Library/Caches/Homebrew/node-0.10.4.tar.gz
==> ./configure --prefix=/usr/local/Cellar/node/0.10.4
==> make install
Warning: Could not link node. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link node'
==> Summary
🍺  /usr/local/Cellar/node/0.10.4: 951 files, 14M, built in 73 seconds

brew link node

$ brew link node
Linking /usr/local/Cellar/node/0.10.4... Warning: Could not link node. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/node/0.10.4/lib/dtrace/node.d
Target /usr/local/lib/dtrace/node.d already exists. You may need to delete it.
To force the link and delete this file, do:
  brew link --overwrite formula_name

To list all files that would be deleted:
  brew link --overwrite --dry-run formula_name

brew link --overwrite node

Linking /usr/local/Cellar/node/0.10.4... Warning: Could not link node. Unlinking...

Error: Permission denied - /usr/local/lib/dtrace/node.d

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

Sudoing homebrew is a bad idea (and doesn't work either) we have to reset the permissions within /usr/local

$ sudo chown -R $(whoami) /usr/local
Password:
$ brew link --overwrite node
Linking /usr/local/Cellar/node/0.10.4... 5 symlinks created

IT WORKS! :-)

STEPS

brew update

brew upgrade

brew cleanup

brew install node

brew link --overwrite node

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

@ldong

This comment has been minimized.

Show comment
Hide comment
@ldong

ldong Sep 22, 2015

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

ldong commented Sep 22, 2015

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

@alphapilgrim

This comment has been minimized.

Show comment
Hide comment
@alphapilgrim

alphapilgrim Sep 29, 2015

Thank you for your help.

alphapilgrim commented Sep 29, 2015

Thank you for your help.

@wealthychef1

This comment has been minimized.

Show comment
Hide comment
@wealthychef1

wealthychef1 Mar 12, 2016

Um, sounds great, unless there are TWO users on your system, and the other one wants to use brew as well. Then what? This is horrible and makes me think I should definitely not use brew.

wealthychef1 commented Mar 12, 2016

Um, sounds great, unless there are TWO users on your system, and the other one wants to use brew as well. Then what? This is horrible and makes me think I should definitely not use brew.

@cedx

This comment has been minimized.

Show comment
Hide comment
@cedx

cedx Mar 14, 2016

sudo chown -R $(whoami) /usr/local : a bad idea too ! I don't see why sudoing Homebrew is a worst idea.

cedx commented Mar 14, 2016

sudo chown -R $(whoami) /usr/local : a bad idea too ! I don't see why sudoing Homebrew is a worst idea.

@ryanjsfx

This comment has been minimized.

Show comment
Hide comment
@ryanjsfx

ryanjsfx Jul 26, 2016

sudo chown -R $(whoami) /usr/local is a terrible idea! I'd rather just sudo when installing; I'm switching to macports

ryanjsfx commented Jul 26, 2016

sudo chown -R $(whoami) /usr/local is a terrible idea! I'd rather just sudo when installing; I'm switching to macports

@aleczadikian

This comment has been minimized.

Show comment
Hide comment
@aleczadikian

aleczadikian Dec 30, 2016

I don't understand why this package manager shouldn't run as root like all other package managers do. Can we just get an option to run brew as root like there used to be (chown'ing brew to root)? I can't install anything without destroying all my permissions. I switched to MacPorts long ago just because of this, but a few things require Homebrew still.

aleczadikian commented Dec 30, 2016

I don't understand why this package manager shouldn't run as root like all other package managers do. Can we just get an option to run brew as root like there used to be (chown'ing brew to root)? I can't install anything without destroying all my permissions. I switched to MacPorts long ago just because of this, but a few things require Homebrew still.

@aleczadikian

This comment has been minimized.

Show comment
Hide comment
@aleczadikian

aleczadikian Dec 30, 2016

Here's what I did to force Homebrew to run as root:
cd /usr/local/Homebrew/Library/Homebrew
Edit brew.sh, look for "Running Homebrew as root is extremely dangerous and no longer supported" (line 250 in my version), delete the check.

aleczadikian commented Dec 30, 2016

Here's what I did to force Homebrew to run as root:
cd /usr/local/Homebrew/Library/Homebrew
Edit brew.sh, look for "Running Homebrew as root is extremely dangerous and no longer supported" (line 250 in my version), delete the check.

@EmadMokhtar

This comment has been minimized.

Show comment
Hide comment
@EmadMokhtar

EmadMokhtar Mar 1, 2017

Perfect it worked for other error, but it is related to Permission denied.

EmadMokhtar commented Mar 1, 2017

Perfect it worked for other error, but it is related to Permission denied.

@065673

This comment has been minimized.

Show comment
Hide comment
@065673

065673 Jun 12, 2017

Before
~/scripts/ripe-atlas-community-contrib$ brew link --overwrite python
Linking /usr/local/Cellar/python/2.7.13... Error: Permission denied - /usr/local/Frameworks
After
sudo chown -R $(whoami) /usr/local/
Result
brew link --overwrite python
Linking /usr/local/Cellar/python/2.7.13... 321 symlinks created == 👍

065673 commented Jun 12, 2017

Before
~/scripts/ripe-atlas-community-contrib$ brew link --overwrite python
Linking /usr/local/Cellar/python/2.7.13... Error: Permission denied - /usr/local/Frameworks
After
sudo chown -R $(whoami) /usr/local/
Result
brew link --overwrite python
Linking /usr/local/Cellar/python/2.7.13... 321 symlinks created == 👍

@aljex

This comment has been minimized.

Show comment
Hide comment
@aljex

aljex Jul 14, 2017

"I switched to MacPorts long ago just because of this" Me too.

It is utterly insane that a package/ports manager actually instructs and requires something so wrong. The justifications cited in their faq essentially serves as self-documenting automatic disqualification from any conversation about system design and operation. That whole section of the faq is just one wrong statement built on top of a previous wrong statement, built on yet an earlier wrong statement. The faq should serve as proof why not to touch any software produced by anyone who produced that faq.

aljex commented Jul 14, 2017

"I switched to MacPorts long ago just because of this" Me too.

It is utterly insane that a package/ports manager actually instructs and requires something so wrong. The justifications cited in their faq essentially serves as self-documenting automatic disqualification from any conversation about system design and operation. That whole section of the faq is just one wrong statement built on top of a previous wrong statement, built on yet an earlier wrong statement. The faq should serve as proof why not to touch any software produced by anyone who produced that faq.

@pointum

This comment has been minimized.

Show comment
Hide comment
@pointum

pointum Oct 21, 2017

No need to chown the whole /usr/local if brew only fails to create a single directory.

For example, I fixed this error:

Permission denied @ dir_s_mkdir - /usr/local/Frameworks

With this command:

sudo install -d -o $(whoami) -g admin /usr/local/Frameworks

pointum commented Oct 21, 2017

No need to chown the whole /usr/local if brew only fails to create a single directory.

For example, I fixed this error:

Permission denied @ dir_s_mkdir - /usr/local/Frameworks

With this command:

sudo install -d -o $(whoami) -g admin /usr/local/Frameworks

@neilrencn

This comment has been minimized.

Show comment
Hide comment
@neilrencn

neilrencn Nov 1, 2017

@pointum
it worked well for us.

neilrencn commented Nov 1, 2017

@pointum
it worked well for us.

@giovanigenerali

This comment has been minimized.

Show comment
Hide comment

giovanigenerali commented Nov 13, 2017

@pointum thanks!

@mohnjatthews

This comment has been minimized.

Show comment
Hide comment
@mohnjatthews

mohnjatthews Nov 14, 2017

@pointum, running sudo install -d -o ($whoami) -g admin /usr/local/Frameworks allowed me to propely link my Python install. Thanks.

mohnjatthews commented Nov 14, 2017

@pointum, running sudo install -d -o ($whoami) -g admin /usr/local/Frameworks allowed me to propely link my Python install. Thanks.

@mihkell

This comment has been minimized.

Show comment
Hide comment
@mihkell

mihkell Nov 16, 2017

sudo chown -R $(whoami) $(brew --prefix)/* is the how todo it in High Sierra

mihkell commented Nov 16, 2017

sudo chown -R $(whoami) $(brew --prefix)/* is the how todo it in High Sierra

@sidepelican

This comment has been minimized.

Show comment
Hide comment
@sidepelican

sidepelican commented Nov 19, 2017

@pointum thanks!

@Sam-Butler

This comment has been minimized.

Show comment
Hide comment
@Sam-Butler

Sam-Butler Nov 28, 2017

@pointum that did the trick

Sam-Butler commented Nov 28, 2017

@pointum that did the trick

@qiuhuaqi

This comment has been minimized.

Show comment
Hide comment
@qiuhuaqi

qiuhuaqi Nov 29, 2017

@pointum Thanks for the tip, sudo install -d -o $(whoami) -g admin worked for me too. Could you (or someone) explain what this line does? (yep I ran a sudo command before understanding what it is ...)

qiuhuaqi commented Nov 29, 2017

@pointum Thanks for the tip, sudo install -d -o $(whoami) -g admin worked for me too. Could you (or someone) explain what this line does? (yep I ran a sudo command before understanding what it is ...)

@iSteveyang

This comment has been minimized.

Show comment
Hide comment
@iSteveyang

iSteveyang commented Dec 1, 2017

@pointum Thanks!

@yfenes

This comment has been minimized.

Show comment
Hide comment
@yfenes

yfenes Dec 8, 2017

@pointum Thanks! It worked for me too.

yfenes commented Dec 8, 2017

@pointum Thanks! It worked for me too.

@kode54

This comment has been minimized.

Show comment
Hide comment
@kode54

kode54 Dec 12, 2017

Bailed to MacPorts.

kode54 commented Dec 12, 2017

Bailed to MacPorts.

@annjawn

This comment has been minimized.

Show comment
Hide comment
@annjawn

annjawn Dec 19, 2017

@pointum that worked for me too. Thank you!

annjawn commented Dec 19, 2017

@pointum that worked for me too. Thank you!

@aether2501

This comment has been minimized.

Show comment
Hide comment
@aether2501

aether2501 Dec 19, 2017

after upgrading to High Sierra, uninstall brew & re-install with the below command to ensure the linking to the brew github and associated permissions to the local folder work correctly:

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

aether2501 commented Dec 19, 2017

after upgrading to High Sierra, uninstall brew & re-install with the below command to ensure the linking to the brew github and associated permissions to the local folder work correctly:

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

@ThuggishNuggets

This comment has been minimized.

Show comment
Hide comment
@ThuggishNuggets

ThuggishNuggets Dec 21, 2017

@aether2501 wrote:

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

This worked perfectly. No mucking around with permissions myself, just reinstalled Homebrew and it works!

Sucks that brew doctor isn't able to fix this.

ThuggishNuggets commented Dec 21, 2017

@aether2501 wrote:

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

This worked perfectly. No mucking around with permissions myself, just reinstalled Homebrew and it works!

Sucks that brew doctor isn't able to fix this.

@MacMeDan

This comment has been minimized.

Show comment
Hide comment
@MacMeDan

MacMeDan commented Jan 1, 2018

@aether2501 is my hero.

@zhjuncai

This comment has been minimized.

Show comment
Hide comment
@zhjuncai

zhjuncai Jan 2, 2018

@pointum save my morning.... thanks

zhjuncai commented Jan 2, 2018

@pointum save my morning.... thanks

@AnalyzePlatypus

This comment has been minimized.

Show comment
Hide comment

AnalyzePlatypus commented Jan 3, 2018

@syokensyo

This comment has been minimized.

Show comment
Hide comment
@syokensyo

syokensyo Jan 10, 2018

@aether2501
awesome solution!

syokensyo commented Jan 10, 2018

@aether2501
awesome solution!

@alexdd55

This comment has been minimized.

Show comment
Hide comment
@alexdd55

alexdd55 Jan 10, 2018

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

alexdd55 commented Jan 10, 2018

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

@j3pic

This comment has been minimized.

Show comment
Hide comment
@j3pic

j3pic Jan 12, 2018

The procedure above didn't work for me. All permissions seemed correct as far as I could tell with /bin/ls. My solution was to edit /usr/local/Homebrew/Library/Homebrew/brew.sh and comment out the line that checks if it's running as root.

j3pic commented Jan 12, 2018

The procedure above didn't work for me. All permissions seemed correct as far as I could tell with /bin/ls. My solution was to edit /usr/local/Homebrew/Library/Homebrew/brew.sh and comment out the line that checks if it's running as root.

@idevz

This comment has been minimized.

Show comment
Hide comment
@idevz

idevz commented Jan 14, 2018

@pointum thanks!

@goelmk

This comment has been minimized.

Show comment
Hide comment
@goelmk

goelmk commented Jan 19, 2018

@pointum thanks!

@rohan20

This comment has been minimized.

Show comment
Hide comment
@rohan20

rohan20 commented Jan 20, 2018

@aether2501 Thanks alot!

@bitakou

This comment has been minimized.

Show comment
Hide comment
@bitakou

bitakou Jan 24, 2018

a command from @pointum really helps!
Thank you <3

bitakou commented Jan 24, 2018

a command from @pointum really helps!
Thank you <3

@emanoelopes

This comment has been minimized.

Show comment
Hide comment
@emanoelopes

emanoelopes commented Jan 25, 2018

@pointum thanks!

@DanDvoracek

This comment has been minimized.

Show comment
Hide comment
@DanDvoracek

DanDvoracek commented Jan 27, 2018

Thanks @pointum !

@gauravparvadiya

This comment has been minimized.

Show comment
Hide comment

gauravparvadiya commented Feb 15, 2018

Thanks @pointum

@stellamiranda

This comment has been minimized.

Show comment
Hide comment
@stellamiranda

stellamiranda commented Feb 20, 2018

thanks @pointum !

@Rondim

This comment has been minimized.

Show comment
Hide comment
@Rondim

Rondim commented Feb 27, 2018

thanks @pointum

@Linesmerrill

This comment has been minimized.

Show comment
Hide comment

Linesmerrill commented Mar 2, 2018

Thanks @mihkell

@samhigh

This comment has been minimized.

Show comment
Hide comment
@samhigh

samhigh commented Mar 16, 2018

@mihkell thanks!

@gregaeq

This comment has been minimized.

Show comment
Hide comment
@gregaeq

gregaeq Mar 20, 2018

@mihkell & @pointum Thanks

My solution was similar, my directory /usr/local/Frameworks didn't exist yet, I was able to just sudo mkdir Frameworks && sudo chown $(whoami) Frameworks/. After that, running brew link python worked.

gregaeq commented Mar 20, 2018

@mihkell & @pointum Thanks

My solution was similar, my directory /usr/local/Frameworks didn't exist yet, I was able to just sudo mkdir Frameworks && sudo chown $(whoami) Frameworks/. After that, running brew link python worked.

@salmanwaheed

This comment has been minimized.

Show comment
Hide comment
@salmanwaheed

salmanwaheed commented Mar 26, 2018

👍

@rjforbes

This comment has been minimized.

Show comment
Hide comment
@rjforbes

rjforbes Apr 12, 2018

@gregaeq I did the same with success. OSX 10.13.3

rjforbes commented Apr 12, 2018

@gregaeq I did the same with success. OSX 10.13.3

@profmocs

This comment has been minimized.

Show comment
Hide comment
@profmocs

profmocs Apr 25, 2018

I just changed the group recursively of /usr/local to wheel, made /usr/local and it contents group writable, and added myself to the wheel group.

profmocs commented Apr 25, 2018

I just changed the group recursively of /usr/local to wheel, made /usr/local and it contents group writable, and added myself to the wheel group.

@FumiyaShibusawa

This comment has been minimized.

Show comment
Hide comment
@FumiyaShibusawa

FumiyaShibusawa May 6, 2018

@gregaeq thanks, it worked with that!

FumiyaShibusawa commented May 6, 2018

@gregaeq thanks, it worked with that!

@christianwgd

This comment has been minimized.

Show comment
Hide comment
@christianwgd

christianwgd May 9, 2018

I agree with aljex, this speaks for itself:

iMac:~ username$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This script requires the user username to be an Administrator.
iMac:~ username$ sudo /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Password:
Don't run this as root!
iMac:~ username$

christianwgd commented May 9, 2018

I agree with aljex, this speaks for itself:

iMac:~ username$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This script requires the user username to be an Administrator.
iMac:~ username$ sudo /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Password:
Don't run this as root!
iMac:~ username$
@gabriel-a

This comment has been minimized.

Show comment
Hide comment
@gabriel-a

gabriel-a May 15, 2018

/usr/local can no longer be chowned in High Sierra.

I tried this.
sudo chown -R $(whoami) $(brew --prefix)/*

gabriel-a commented May 15, 2018

/usr/local can no longer be chowned in High Sierra.

I tried this.
sudo chown -R $(whoami) $(brew --prefix)/*

@caiocesarf

This comment has been minimized.

Show comment
Hide comment
@caiocesarf

caiocesarf commented May 15, 2018

thanks! @pointum

@chuckiefan

This comment has been minimized.

Show comment
Hide comment
@chuckiefan

chuckiefan May 21, 2018

@pointum Thank you, it works for me!

chuckiefan commented May 21, 2018

@pointum Thank you, it works for me!

@Jkim55

This comment has been minimized.

Show comment
Hide comment
@Jkim55

Jkim55 commented Jun 5, 2018

@aether2501, thanks!!

@manideepak5298

This comment has been minimized.

Show comment
Hide comment
@manideepak5298

manideepak5298 Jun 9, 2018

@aether2501, thanks. It really helped me.

manideepak5298 commented Jun 9, 2018

@aether2501, thanks. It really helped me.

@PhyllisWong

This comment has been minimized.

Show comment
Hide comment
@PhyllisWong

PhyllisWong Jun 19, 2018

Didn't work for me:
sudo chown -R $(whoami) /usr/local

However this command did:
sudo chown -R $(whoami) $(brew --prefix)/*

PhyllisWong commented Jun 19, 2018

Didn't work for me:
sudo chown -R $(whoami) /usr/local

However this command did:
sudo chown -R $(whoami) $(brew --prefix)/*

@OxyFlax

This comment has been minimized.

Show comment
Hide comment
@OxyFlax

OxyFlax Jun 29, 2018

Thank you @PhyllisWong, it worked like a charm

OxyFlax commented Jun 29, 2018

Thank you @PhyllisWong, it worked like a charm

@aareeph

This comment has been minimized.

Show comment
Hide comment
@aareeph

aareeph Jul 7, 2018

@pointum your solutioni worked like a charm! Thanks! :)

aareeph commented Jul 7, 2018

@pointum your solutioni worked like a charm! Thanks! :)

@brannonh

This comment has been minimized.

Show comment
Hide comment
@brannonh

brannonh Jul 9, 2018

@aether2501's solution worked perfectly for me. Reinstalling Homebrew seems like the best option here.

brannonh commented Jul 9, 2018

@aether2501's solution worked perfectly for me. Reinstalling Homebrew seems like the best option here.

@RoRroland

This comment has been minimized.

Show comment
Hide comment
@RoRroland

RoRroland Jul 10, 2018

this one works for me. sudo chown -R $(whoami) $(brew --prefix)/*

RoRroland commented Jul 10, 2018

this one works for me. sudo chown -R $(whoami) $(brew --prefix)/*

@raviranjan0631

This comment has been minimized.

Show comment
Hide comment
@raviranjan0631

raviranjan0631 Jul 20, 2018

it was due to npm cache error and it can be solved by
clearing the cache
"npm cache clear --force"

raviranjan0631 commented Jul 20, 2018

it was due to npm cache error and it can be solved by
clearing the cache
"npm cache clear --force"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment