How to fix 'fatal: cannot create directory at '.github': Permission denied' error with brew update

Tadashi Shigeoka ·  Sun, April 24, 2016

When running brew update on Mac, if you get this error message:

$ brew update
fatal: cannot create directory at '.github': Permission denied
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

I’ll introduce how to fix it.

Change permissions for the /usr/local directory

The error message fatal: cannot create directory at ‘.github’: Permission denied appears because there are no permissions for the /usr/local directory.

Use the chown command to change ownership to yourself.

$ ls -la /usr/local
total 112
drwxr-xr-x   24 root     wheel    816 Oct 28 08:47 .
$ sudo chown $(whoami):admin /usr/local
$ ls -la /usr/local
total 112
drwxr-xr-x   24 myname  admin    816 Oct 28 08:47 .

Update Homebrew's GitHub repository to master

cd `brew --prefix`
git fetch origin
git reset --hard origin/master

Finally, update Homebrew

$ brew update
$ brew -v
Homebrew 0.9.9 (git revision 145155; last commit 2016-04-23)
Homebrew/homebrew-core (git revision bd06; last commit 2016-04-23)

That’s all from the Gemba.