Homebrew-cask: Error: Permission denied

Created on 17 Jun 2016  Â·  28Comments  Â·  Source: Homebrew/homebrew-cask

Description of issue

Every time I user brew cask install , I face the same issue. But I still can use brew install..

Output of brew cask install filezilla --verbose

==> Downloading http://downloads.sourceforge.net/project/filezilla/FileZilla_Client/3.18.0/FileZilla_3.18.0_macosx-x86.app.tar.bz2
Already downloaded: /Users/jihan/Library/Caches/Homebrew/filezilla-3.18.0.tar.bz2
==> Verifying checksum for Cask filezilla
==> Moving App 'FileZilla.app' to '/Applications/FileZilla.app'
Error: Permission denied - (/usr/local/Caskroom/filezilla/3.18.0/FileZilla.app, /Applications/FileZilla.app)
  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:519:in `rename'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:519:in `block in mv'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:1558:in `block in fu_each_src_dest'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:1574:in `fu_each_src_dest0'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:1556:in `fu_each_src_dest'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:508:in `mv'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/artifact/moved.rb:50:in `move'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/artifact/moved.rb:26:in `block in install_phase'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/artifact/moved.rb:43:in `block in each_artifact'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/artifact/moved.rb:42:in `each'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/artifact/moved.rb:42:in `each_artifact'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/artifact/moved.rb:22:in `install_phase'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/installer.rb:129:in `block in install_artifacts'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/installer.rb:126:in `each'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/installer.rb:126:in `install_artifacts'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/installer.rb:75:in `install'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli/install.rb:21:in `block in install_casks'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli/install.rb:18:in `each'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli/install.rb:18:in `install_casks'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli/install.rb:7:in `run'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli.rb:83:in `run_command'
/usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli.rb:121:in `process'
/usr/local/Library/Taps/caskroom/homebrew-cask/cmd/brew-cask.rb:26:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/local/Library/brew.rb:22:in `require?'
/usr/local/Library/brew.rb:93:in `<main>'
Error: Kernel.exit

Output of brew doctor

Your system is ready to brew.

Output of brew cask doctor

==> macOS Release:
10.11
==> macOS Release with Patchlevel:
10.11.5
==> Hardware Architecture:
intel-64
==> Ruby Version:
2.0.0-p648
==> Ruby Path:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
==> Homebrew Version:
Homebrew 0.9.9 (git revision 96cb; last commit 2016-06-17)
Homebrew/homebrew-core (git revision b1d0; last commit 2016-06-17)
==> Homebrew Executable Path:
/usr/local/bin/brew
==> Homebrew Cellar Path:
/usr/local/Cellar
==> Homebrew Repository Path:
/usr/local
==> Homebrew Origin:
https://github.com/Homebrew/brew
==> Homebrew-cask Version:
0.60.0 (git revision 51e2; last commit 29 minutes ago)
==> Homebrew-cask Install Location:
<NONE>
==> Homebrew-cask Staging Location:
/usr/local/Caskroom
==> Homebrew-cask Cached Downloads:
/Users/jihan/Library/Caches/Homebrew
/Users/jihan/Library/Caches/Homebrew/Casks
2 files, 14.6M (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:
3211
==> Contents of $LOAD_PATH:
/usr/local/Library/Taps/caskroom/homebrew-cask/lib
/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="/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Library/Taps/caskroom/homebrew-cask/cmd:/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

Most helpful comment

I had the same error message:

Error: Permission denied - (/Users/jt3k/Library/Caches/Homebrew/black-screen-0.0.3.zip, /Users/jt3k/Library/Caches/Homebrew/Casks/black-screen-0.0.3.zip)

Following command fixed my problem.

sudo chown -R $(whoami):staff ~/Library/Caches/Homebrew /opt/homebrew-cask/

thanx

All 28 comments

Got a similar issue:

$ brew install Caskroom/cask/dockertoolbox
==> brew cask install Caskroom/cask/dockertoolbox
Warning: The default Caskroom location has moved to /usr/local/homebrew/Caskroom.

Please migrate your Casks to the new location, or if you would like to keep your
Caskroom at /opt/homebrew-cask/Caskroom, add the following to your HOMEBREW_CASK_OPTS:

  --caskroom=/opt/homebrew-cask/Caskroom

For more details on each of those options, see https://github.com/caskroom/homebrew-cask/issues/21913.
==> Satisfying dependencies
==> Installing Cask dependencies: virtualbox
virtualbox ...
==> Downloading http://download.virtualbox.org/virtualbox/5.0.22/VirtualBox-5.0.22-108108-OSX.dmg
######################################################################## 100.0%
==> Verifying checksum for Cask virtualbox
Error: Permission denied - /opt/homebrew-cask/Caskroom/virtualbox/5.0.22-108108
  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'
/usr/local/homebrew/Library/Taps/caskroom/homebrew-cask/lib/hbc/installer.rb:109:in `extract_primary_container'
/usr/local/homebrew/Library/Taps/caskroom/homebrew-cask/lib/hbc/installer.rb:74:in `install'
/usr/local/homebrew/Library/Taps/caskroom/homebrew-cask/lib/hbc/installer.rb:214:in `block in cask_dependencies'
/usr/local/homebrew/Library/Taps/caskroom/homebrew-cask/lib/hbc/installer.rb:207:in `each'
/usr/local/homebrew/Library/Taps/caskroom/homebrew-cask/lib/hbc/installer.rb:207:in `cask_dependencies'
/usr/local/homebrew/Library/Taps/caskroom/homebrew-cask/lib/hbc/installer.rb:143:in `satisfy_dependencies'
/usr/local/homebrew/Library/Taps/caskroom/homebrew-cask/lib/hbc/installer.rb:71:in `install'
/usr/local/homebrew/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli/install.rb:21:in `block in install_casks'
/usr/local/homebrew/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli/install.rb:18:in `each'
/usr/local/homebrew/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli/install.rb:18:in `install_casks'
/usr/local/homebrew/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli/install.rb:7:in `run'
/usr/local/homebrew/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli.rb:83:in `run_command'
/usr/local/homebrew/Library/Taps/caskroom/homebrew-cask/lib/hbc/cli.rb:121:in `process'
/usr/local/homebrew/Library/Taps/caskroom/homebrew-cask/cmd/brew-cask.rb:26:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/local/homebrew/Library/brew.rb:22:in `require?'
/usr/local/homebrew/Library/brew.rb:93:in `<main>'

i have same problem

What are the permissions on that directory, and all of them to the top (/opt, /opt/homebrew-cask, …)?

So, for some reason caprine is under root. I’m guessing we’ll see a similar pattern from @surfer190 and @abuumair-dsi.

I ask that you correct the ownership of the directories. This is likely due to one of the recent changes. Only to worry if it happens again, after you manually correct the ownership.

I had the same error message:

Error: Permission denied - (/Users/jt3k/Library/Caches/Homebrew/black-screen-0.0.3.zip, /Users/jt3k/Library/Caches/Homebrew/Casks/black-screen-0.0.3.zip)

Following command fixed my problem.

sudo chown -R $(whoami):staff ~/Library/Caches/Homebrew /opt/homebrew-cask/

thanx

@vitorgalvao , thanks for your help... ls: /opt: No such file or directory what should I do now?

Im my case (#22081) changing ownership doesn't help, tried:

sudo chown -R $(whoami):staff ~/Library/Caches/Homebrew /usr/local/Caskroom/ /usr/local/Library/Homebrew/

Before: userid:admin; After: userid:stuff

Yes like @jt3k my problem was solved by giving ownership of all the files in the homebrew-cask folder to my user.

@abuumair-dsi You are probably using the new cask location: /usr/local/Caskroom/

@abuumair-dsi You are probably using the new cask location: /usr/local/Caskroom/

That is correct. Look at your error, @abuumair-dsi, and you’ll see that is the case. Run the command to that directory.

It's solved my problem
sudo chown -R $(whoami):staff /Applications/

Thanks everyone..

In my case the issue not not been solved that way, I get mostly "Operation not permitted" via chown on /Applications, example

sudo chown -R $(whoami):staff /Applications/
...
chown: /Applications/App Store.app: Operation not permitted
chown: /Applications/Automator.app: Operation not permitted

Can someone explain, what is the root-cause if this issue?

In my case my user is member of the "admin" group and mostly in the filesystems the dirs are assigned to the admin group. What is the reason to try to change the different directories to staff? Is staff been used in homebrew as default?

@mathiashro You shouldn’t be trying to change the permissions of /Applications, but of your Caskroom.

The group is irrelevant, just your user needs to be correct.

OK. Clear. I did checked the user, everything looks good:

$ whoami
mat
$ ls -la /usr/local/Caskroom/
total 0
drwxr-xr-x   9 mat  admin  306 26 Apr 21:10 .
drwxr-xr-x@ 29 mat  admin  986 17 Jun 12:32 ..
...
drwxr-xr-x   4 mat  admin  136 19 Jun 19:50 bitcoin-core
...
$ brew cask install bitcoin-core
==> Downloading https://bitcoin.org/bin/bitcoin-core-0.12.1/bitcoin-0.12.1-osx.dmg
Already downloaded: /Users/mat/Library/Caches/Homebrew/bitcoin-core-0.12.1.dmg
==> Verifying checksum for Cask bitcoin-core
==> Moving App 'Bitcoin-Qt.app' to '/Applications/Bitcoin Core.app'
Error: Permission denied - (/usr/local/Caskroom/bitcoin-core/0.12.1/Bitcoin-Qt.app, /Applications/Bitcoin Core.app)

Try to install with --force.

Same result. Output:

$ brew cask install --force bitcoin-core
==> Downloading https://bitcoin.org/bin/bitcoin-core-0.12.1/bitcoin-0.12.1-osx.dmg
Already downloaded: /Users/mat/Library/Caches/Homebrew/bitcoin-core-0.12.1.dmg
==> Verifying checksum for Cask bitcoin-core
==> Moving App 'Bitcoin-Qt.app' to '/Applications/Bitcoin Core.app'
Error: Permission denied - (/usr/local/Caskroom/bitcoin-core/0.12.1/Bitcoin-Qt.app, /Applications/Bitcoin Core.app)

@mathiashro
show me the output of this commands

ll /usr/local/Caskroom/ #need only a part of the output
groups
ll /Applications # need only a part of the output

See also above. Here the requested output:

$ ls -la /usr/local/Caskroom/
total 0
drwxr-xr-x   9 mat  admin  306 26 Apr 21:10 .
drwxr-xr-x@ 29 mat  admin  986 17 Jun 12:32 ..
...
drwxr-xr-x   4 mat  admin  136 19 Jun 20:09 bitcoin-core
...
$ ls -la /Applications/
total 72
drwxrwxr-x+ 117 root  admin   3978 17 Jun 20:26 .
drwxr-xr-x   38 root  wheel   1360 16 Mai 20:59 ..
-rw-rw-r--    1 mat   staff  28676 17 Jun 20:28 .DS_Store
-rw-r--r--    1 mat   staff      0 23 Aug  2015 .localized
drwxr-xr-x@   4 mat   admin    136 17 Mär 18:28 ....app
drwxrwxr-x@   6 mat   admin    204 28 Jan 10:19 ...
drwxr-xr-x@   3 mat   admin    102  7 Nov  2013 ....app
drwxr-xr-x    3 mat   admin    102  4 Dez  2015 .....app
-rw-r--r--    1 mat   admin      0 28 Apr 21:14 .....log
drwxr-xr-x@   3 mat   admin    102  6 Dez  2012 .....app
drwxr-xr-x@   3 root  wheel    102 16 Mai 21:00 App Store.app
...

(Removed the real app names.)

So in this case, the issue is with Bitcoin Core itself. See https://github.com/caskroom/homebrew-cask/pull/22248.

@mathiashro sorry. i have no idea.
go to link by @vitorgalvao

What if the current user is not in admin group?

@cybertk Install to another directory, then: https://github.com/caskroom/homebrew-cask/issues/22335#issuecomment-228004961.

My caskroom is in /Users/robindegen/Scripts/brew/Caskroom/, and is (since it's in my home folder) owned by my user. I still get the the same error.

==> Moving App 'kdiff3.app' to '/Applications/kdiff3.app'
Error: Permission denied - (/Users/robindegen/Scripts/brew/Caskroom/kdiff3/0.9.98/kdiff3.app, /Applications/kdiff3.app)

@robindegen Trouble is where it’s installing to, not from.

I was getting this:

$ brew cask reinstall xquartz
==> Migrating Caskroom from /opt/homebrew-cask/Caskroom to /usr/local/Caskroom.
Error: Permission denied - (/opt/homebrew-cask/Caskroom, /usr/local/Caskroom)
Follow the instructions here:
  https://github.com/caskroom/homebrew-cask#reporting-bugs
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:519:in `rename'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:519:in `block in mv'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:1558:in `block in fu_each_src_dest'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:1574:in `fu_each_src_dest0'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:1556:in `fu_each_src_dest'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/fileutils.rb:508:in `mv'
/usr/local/Homebrew/Library/Homebrew/compat/hbc/caskroom.rb:15:in `migrate_legacy_caskroom'
/usr/local/Homebrew/Library/Homebrew/compat/hbc.rb:15:in `init'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:167:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:132:in `run'
/usr/local/Homebrew/Library/Homebrew/cmd/cask.rb:8:in `cask'
/usr/local/Homebrew/Library/Homebrew/brew.rb:100:in `<main>'

and the fix was to

mkdir /usr/local/Caskroom

fix my issue with this command sudo chown -R $(whoami):staff /usr/local/Caskroom

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seanreed1111 picture seanreed1111  Â·  3Comments

pablopunk picture pablopunk  Â·  3Comments

florianletsch picture florianletsch  Â·  3Comments

RJHsiao picture RJHsiao  Â·  3Comments

arnogues picture arnogues  Â·  4Comments