I ran brew outdated
in macOS Mojave 10.14.2 and determined that python
and python@2
were outdated. When I ran brew upgrade
it failed for both. For example for python@2
:
==> Upgrading python@2
==> Downloading https://homebrew.bintray.com/bottles/python@2-2.7.15_2.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring python@2-2.7.15_2.mojave.bottle.tar.gz
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/Frameworks
Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks
I ran brew doctor
and it recommends to brew link
but this still fails with the same permission error:
Linking /usr/local/Cellar/python@2/2.7.15_2... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks
This post recommends to grant privileges to the parent directory, but I want to understand why this happens and find a solution for learning.
I found the answer here. I had to
sudo mkdir /usr/local/Frameworks
to create the missing directory first, thensudo chown -R $(whoami) $(brew --prefix)/*
sincesudo chown -R $(whoami) /usr/local
no longer works in Mojave - and High Sierra before that, according to the post. I was able tobrew link python
andbrew link python@2
after that.