Homebrew-cask: Error: Permission denied when try to install a cask

Created on 9 Mar 2016  Â·  16Comments  Â·  Source: Homebrew/homebrew-cask

I am trying to create a cask for VirtualBox, but when I run brew cask install virtualbox, it downloads, and when it tries to verify the checksum, I get a permission denied error. Is this because I am not a sudo user? The same thing happened when I tried to install iTerm2.

OS X El Capitan 10.11.3
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]

Here is my output of brew cask install iterm2 --verbose:

==> Downloading https://iterm2.com/downloads/stable/iTerm2-2_1_4.zip
/usr/bin/curl -fLA Homebrew-cask v0.51+ (Ruby 2.0.0-645) https://iterm2.com/downloads/stable/iTerm2-2_1_4.zip -C 0 -o /Library/Caches/Homebrew/iterm2-2.1.4.zip.incomplete
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 3114k  100 3114k    0     0   222k      0  0:00:13  0:00:13 --:--:--  216k
==> Verifying checksum for Cask iterm2
Error: Permission denied - /opt/homebrew-cask/Caskroom/iterm2
  Most likely, this means you have an outdated version of homebrew-cask. Please run:

      brew uninstall --force brew-cask; brew untap phinze/cask; brew update; brew cleanup; brew cask cleanup

  If this doesn’t fix the problem, please report this bug:

      https://github.com/caskroom/homebrew-cask#reporting-bugs

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:245:in `mkdir'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:245:in `fu_mkdir'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:219:in `block (2 levels) in mkdir_p'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:217:in `reverse_each'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:217:in `block in mkdir_p'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:203:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:203:in `mkdir_p'
/Users/CalebKleveter/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/installer.rb:105:in `extract_primary_container'
/Users/CalebKleveter/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/installer.rb:70:in `install'
/Users/CalebKleveter/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli/install.rb:20:in `block in install_casks'
/Users/CalebKleveter/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli/install.rb:17:in `each'
/Users/CalebKleveter/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli/install.rb:17:in `install_casks'
/Users/CalebKleveter/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli/install.rb:6:in `run'
/Users/CalebKleveter/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli.rb:83:in `run_command'
/Users/CalebKleveter/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli.rb:121:in `process'
/Users/CalebKleveter/usr/local/Library/Taps/caskroom/homebrew-cask/cmd/brew-cask.rb:26:in `<top (required)>'
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/CalebKleveter/usr/local/Library/brew.rb:21:in `require?'
/Users/CalebKleveter/usr/local/Library/brew.rb:89:in `<main>'
Error: Kernel.exit

Here is the output from brew doctor:

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
    /Library/Frameworks/Python.framework/Versions/3.4/bin/python3-config
    /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4-config
    /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4m-config
    /usr/local/bin/powerline-config
    /usr/local/bin/python3-config
    /usr/local/bin/python3.4-config
    /usr/local/bin/python3.4m-config
    /opt/sm/pkg/active/bin/curl-config
    /opt/sm/pkg/active/bin/ncurses5-config
    /opt/sm/pkg/active/bin/ncursesw5-config
    /opt/sm/pkg/active/bin/pkg-config
    /opt/sm/pkg/active/bin/xml2-config
    /opt/sm/pkg/active/bin/xslt-config

Warning: Python is installed at /Library/Frameworks/Python.framework

Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.

Warning: You have leftover files from an older version of Xcode.
You should delete them using:
  /Developer/Library/uninstall-developer-folder

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

Unexpected static libraries:
    /usr/local/lib/libhelium_mac.a

Warning: Your Homebrew is not installed to /usr/local
You can install Homebrew anywhere you want, but some brews may only build
correctly if you install in /usr/local. Sorry!

Warning: You have a non-Homebrew 'pkg-config' in your PATH:
  /opt/sm/pkg/active/bin/pkg-config

`./configure` may have problems finding brew-installed packages using
this other pkg-config.

And brew cask doctor:

==> OS X Release:
10.11
==> OS X Release with Patchlevel:
10.11.3
==> 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:
Homebrew 0.9.5 (git revision c7238; last commit 2016-03-09)
==> Homebrew Executable Path:
/Users/CalebKleveter/usr/local/bin/brew
==> Homebrew Cellar Path:
/Users/CalebKleveter/usr/local/Cellar
==> Homebrew Repository Path:
/Users/CalebKleveter/usr/local
==> Homebrew Origin:
https://github.com/Homebrew/homebrew
==> Homebrew-cask Version:
0.60.0 (git revision c16c; last commit 15 minutes ago)
==> Homebrew-cask Install Location:
<NONE>
==> 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
2 files, 6M (warning: run "brew cask cleanup")
==> Homebrew-cask Default Tap Path:
/Users/CalebKleveter/usr/local/Library/Taps/caskroom/homebrew-cask
==> Homebrew-cask Alternate Cask Taps:
<NONE>
==> Homebrew-cask Default Tap Cask Count:
3006
==> Contents of $LOAD_PATH:
/Users/CalebKleveter/usr/local/Library/Taps/caskroom/homebrew-cask/lib
/Users/CalebKleveter/usr/local/Library/Homebrew
/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="/Users/CalebKleveter/usr/local/bin:/Users/CalebKleveter/.nvm/versions/node/v5.6.0/bin:/Users/CalebKleveter/.rvm/gems/ruby-2.2.3/bin:/Users/CalebKleveter/.rvm/gems/ruby-2.2.3@global/bin:/Users/CalebKleveter/.rvm/rubies/ruby-2.2.3/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin:/Users/CalebKleveter/.rvm/bin:/Users/CalebKleveter/usr/local/Library/Taps/caskroom/homebrew-cask/cmd:/Users/CalebKleveter/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

I ran the command given, but that didn't fix it.

Most helpful comment

Oh sorry, old instructions. Wipe cask

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

and just try brew cask install virtualbox - Homebrew _should_ handle everything else.

All 16 comments

I ran this command:

brew uninstall brew-cask && brew install caskroom/cask/brew-cask

And got this output:

Error: No such keg: /Users/CalebKleveter/usr/local/Cellar/brew-cask

The installation still does not work, even after re-installing cask. I don't have any problem when I only use Homebrew, and not cask.

Oh sorry, old instructions. Wipe cask

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

and just try brew cask install virtualbox - Homebrew _should_ handle everything else.

Is their a replacement for the last command? I don't have sudo privileges.

A normal rm -rf (or even deleting in Finder) should be sufficient - if it isn't, it's a permissions error that we can't fix without sudo (the normal solution is to chmod).

I forget if this needs sudo, but you can try (after deleting) mkdir /opt/homebrew-cask; chown $(whoami):staff /opt/homebrew-cask

I got a permission denied error when I ran rm -rf '/opt/homebrew-cask'. Whenever I try to uninstall cask I get No such keg: /Users/CalebKleveter/usr/local/Cellar/brew-cask. The issue remains.

Pinging @vitorgalvao

@calebkleveter You should’ve followed the reporting bugs guide, and we ask users to allways do so. I see a few steps here that would’ve been avoided by doing so. In fact, this is especially necessary in your case, since you have an atypical setup (no sudo).

You can’t start the directory at /opt in the first place because you don’t have sudo. Use --caskroom to set it somewhere you can write to.

Whenever I try to uninstall cask I get No such keg: /Users/CalebKleveter/usr/local/Cellar/brew-cask.

Is that where it’s supposed to be? Do you have homebrew installed in a /usr/local under your home? That is really atypical (and one of the reasons we need you to follow the guide on reporting bugs) and they even recommend against it.

What’s the output of brew tap? To get rid of homebrew-cask, try rm -rf "$(brew --repository)/Library/Taps/caskroom.

I just updated the issue. It might help to look at this link. It is how I installed Homebrew because I am not a sudoer.

Error: Permission denied - /opt/homebrew-cask/Caskroom/iterm2

Again:

You can’t start the directory at /opt in the first place because you don’t have sudo. Use --caskroom to set it somewhere you can write to.

Sorry about my confusion. I finally got it by creating a directory Caskroom in my home and going into .bash_profile and adding:

export HOMEBREW_CASK_OPTS="--appdir=~/Applications --caskroom=~/Caskroom"

Thanks! This has really helped me! It really would be helpful if it were easier to find how to change homebrew-cask's appdir.

It's frustrating that a decision was taken to default to trying to install into /Applications, given how many of us use Homebrew without sudo.

How could we make it easier? appdir and HOMEBREW_CASK_OPTS are already in both the documentation and the man page.

How could we make it easier?

Make it easier by telling the user nothing is broken, and give them the workaround for installing casks without sudo (--appdir=~/Applications). Correct me if I'm wrong, but a permissions error will always occur if 1) the user is not using sudo, and 2) /Applications has its default permissions (not user writable). That's probably the majority of users, so help the suckers out (I noticed lots of issues have been raised by users unsure how to proceed). Maybe something like:

Sorry, Homebrew-cask could not install into your /Applications directory because you don't have permission to write to that directory (and you're not using sudo). The best way to proceed is to follow the instructions for specifying a custom applications install directory…

Hi all,

I tried adding the following to my zsh profile and got a different error.

export HOMEBREW_CASK_OPTS="--appdir=~/Applications --caskroom=~/Caskroom"
$ brew cask install iterm2
Warning: Calling `brew cask` with the `--caskroom` flag is deprecated and will be disabled on 2017-10-31!
There is no replacement.

Are there any suggestions for this?

@kdheepak Follow the error message: remove the --caskroom flag.

Was this page helpful?
0 / 5 - 0 ratings