Homebrew-cask: Error: Permission denied - /opt/homebrew-cask/Caskroom/(application)

Created on 5 Dec 2015  路  5Comments  路  Source: Homebrew/homebrew-cask

Unable to install applications.

Already ran:

brew update && brew upgrade brew-cask && brew cleanup && brew cask cleanup

Most helpful comment

Ah, I see it's a permissions error: /opt/homebrew-cask/Caskroom (error: not writable by current user)

Can you please check if sudo ls -arlt /opt/homebrew-cask gives you an output like:

[~] > sudo ls -arlt /opt/homebrew-cask
Password:
total 24
drwxr-xr-x   4 aditya  staff   136 Oct  4 14:31 .
drwxrwxr-x@  4 root    wheel   136 Nov 19 09:40 ..
-rw-r--r--@  1 aditya  staff  8196 Nov 29 12:50 .DS_Store
drwxr-xr-x  24 aditya  staff   816 Dec  6 10:25 Caskroom

If they don't look like that, let's fix that, run:

sudo mkdir -p /opt/homebrew-cask/Caskroom
sudo chown -R ${USER}:staff /opt/homebrew-cask

Try running brew update && brew upgrade -all && brew cleanup && brew cask cleanup after that. If there are no errors, you're good to go.

And finally, if that still doesn't work, the "nuclear" option is:

# NOTE: this will wipe homebrew-cask
brew uninstall brew-cask
brew untap caskroom/cask
sudo rm -rf '/opt/homebrew-cask'
brew install caskroom/cask/brew-cask

Please let us know your results.

All 5 comments

First, make sure brew doctor has no errors.

Please post the output of brew cask doctor and sudo ls -arlt /opt/homebrew-cask

From brew doctor:

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
    /usr/local/include/ublio.h

Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so
    echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile

From brew cask doctor:

==> OS X Release:
10.11
==> OS X Release with Patchlevel:
10.11.1
==> Hardware Architecture:
intel-64
==> Ruby Version:
2.0.0-p645
==> Ruby Path:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
==> Homebrew Version:
0.9.5 (git revision 12f4; last commit 2015-12-06)
==> Homebrew Executable Path:
/usr/local/bin/brew
==> Homebrew Cellar Path:
/usr/local/Cellar
==> Homebrew Repository Path:
/usr/local
==> Homebrew Origin:
https://github.com/Homebrew/homebrew
==> Homebrew-cask Version:
0.59.0
==> Homebrew-cask Install Location:
/usr/local/Cellar/brew-cask/0.59.0
==> Homebrew-cask Staging Location:
/opt/homebrew-cask/Caskroom (error: not writable by current user)
==> Homebrew-cask Cached Downloads:
/Library/Caches/Homebrew
/Library/Caches/Homebrew/Casks
4 files (warning: run "brew cask cleanup")
84.61 megs (warning: run "brew cask cleanup")
==> Homebrew-cask Default Tap Path:
/usr/local/Library/Taps/caskroom/homebrew-cask
==> Homebrew-cask Alternate Cask Taps:
<NONE>
==> Homebrew-cask Default Tap Cask Count:
2903
==> Contents of $LOAD_PATH:
/usr/local/Cellar/brew-cask/0.59.0/rubylib
/Library/Ruby/Site/2.0.0
/Library/Ruby/Site/2.0.0/x86_64-darwin15
/Library/Ruby/Site/2.0.0/universal-darwin15
/Library/Ruby/Site
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/vendor_ruby/2.0.0
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/vendor_ruby/2.0.0/x86_64-darwin15
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/vendor_ruby/2.0.0/universal-darwin15
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/vendor_ruby
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/x86_64-darwin15
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin15
==> Contents of $RUBYLIB Environment Variable:
<NONE>
==> Contents of $RUBYOPT Environment Variable:
<NONE>
==> Contents of $RUBYPATH Environment Variable:
<NONE>
==> Contents of $RBENV_VERSION Environment Variable:
<NONE>
==> Contents of $CHRUBY_VERSION Environment Variable:
<NONE>
==> Contents of $GEM_HOME Environment Variable:
<NONE>
==> Contents of $GEM_PATH Environment Variable:
<NONE>
==> Contents of $BUNDLE_PATH Environment Variable:
<NONE>
==> Contents of $PATH Environment Variable:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Library/ENV/scm"
==> Contents of $SHELL Environment Variable:
SHELL="/bin/bash"
==> Contents of Locale Environment Variables:
LANG="en_US.UTF-8"
==> Running As Privileged User:
No

Thank you for your helping!

Ah, I see it's a permissions error: /opt/homebrew-cask/Caskroom (error: not writable by current user)

Can you please check if sudo ls -arlt /opt/homebrew-cask gives you an output like:

[~] > sudo ls -arlt /opt/homebrew-cask
Password:
total 24
drwxr-xr-x   4 aditya  staff   136 Oct  4 14:31 .
drwxrwxr-x@  4 root    wheel   136 Nov 19 09:40 ..
-rw-r--r--@  1 aditya  staff  8196 Nov 29 12:50 .DS_Store
drwxr-xr-x  24 aditya  staff   816 Dec  6 10:25 Caskroom

If they don't look like that, let's fix that, run:

sudo mkdir -p /opt/homebrew-cask/Caskroom
sudo chown -R ${USER}:staff /opt/homebrew-cask

Try running brew update && brew upgrade -all && brew cleanup && brew cask cleanup after that. If there are no errors, you're good to go.

And finally, if that still doesn't work, the "nuclear" option is:

# NOTE: this will wipe homebrew-cask
brew uninstall brew-cask
brew untap caskroom/cask
sudo rm -rf '/opt/homebrew-cask'
brew install caskroom/cask/brew-cask

Please let us know your results.

Closing due to lack of reply

Thanks @adidalal . It worked for me without needing to use the _Nuclear option_.

Was this page helpful?
0 / 5 - 0 ratings