1

Running Darwin Home 18.5.0 Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64 x86_64

Trying to finish updating python... but failing to link it cause of the security on this platform.

You can use `brew link python` to link this version.
Home:~ localadmin$ brew link python
Linking /usr/local/Cellar/python/3.7.3... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks
Home:~ localadmin$ sudo brew link python
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.

How do I get around this? Can I ask brew to tell me what it is trying to do here perhaps?

user3069232
  • 125
  • 5

1 Answers1

1

In earlier versions of MacOSX, the easy fix was to change ownership on /usr/local so that you could create directories in it without using sudo. However, since High Sierra, this is no longer possible - the operating system forbids it entirely.

So the workaround is to create these required folders as root, and then change ownership of them to yourself or to a group you're a member of and make sure they're writable for you, like so:

sudo mkdir /usr/local/Frameworks

To change ownership to yourself:

sudo chown YOURUSERNAME /usr/local/Frameworks

To change ownership to the admin group and grant write permissions:

sudo chgrp admin /usr/local/Frameworks
sudo chmod g+w /usr/local/Frameworks

Unfortunately you'll have to keep doing this for all directories that will need to be created under /usr/local.

Jenny D
  • 13,022
  • 3
  • 38
  • 54
  • Jenny, maybe I am losing it but none of these commands work. I keep getting Operation not permitted, even when I sudo su - root. – user3069232 May 11 '19 at 13:14
  • Huh, this was apparently changed in High Sierra so it's no longer possible. (This is why it's better to post Mac questions in [apple.se]...) But there's a workaround, I'll change my answer. – Jenny D May 11 '19 at 13:22
  • I'm glad it worked! If you click on the checkmark by the answer, that will make it clear to others that this answer worked, so it'll be easier for others with the same problem to find it. – Jenny D May 11 '19 at 19:31