Cometsong
Cometsong

Reputation: 578

ruby "permission denied" installing/using homebrew cask

My wild bet is that this issue is somehow related to my base osx ruby setup... but as I'm not a ruby-ite, i need some guidance to discover more.

A couple days ago i tried to install a brew cask formula (several others were already installed previously). A couple weeks ago i upgraded to OSX Sierra.

Brew itself works perfectly, brew cask does not.

I get an "unexpected" error when I type brew cask by itself or with any subcommand:

Error: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for ruby/st.h... yes
checking for st.h... yes
checking for rb_str_replace() in ruby.h... yes
creating Makefile
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:2125:in `initialize': Permission denied - Makefile (Errno::EACCES)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:2125:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:2125:in `create_makefile'
    from extconf.rb:24:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/msgpack-0.5.8 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-16/2.0.0/msgpack-0.5.8/gem_make.out

I've looked through many questions and tried many of the answers given, all to no avail.

Questions:
Homebrew cask option not recognized?
Failed to build gem native extension (installing Compass)
homebrew not working on OSX Can't install Brew formulae correctly (Permission denied in /usr/local/lib)
OsX, can't use Homebrew because of Ruby permission

Attempts:

> xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

> brew install ruby
Warning: ruby-2.4.0 already installed

> ls -l /System/Library/Frameworks/Ruby.framework/Versions/
drwxr-xr-x 7 root wheel 238 2017-01-12 12:12:13 2.0
lrwxr-xr-x 1 root wheel   3 2017-01-09 09:47:51 Current -> 2.0

> sudo chown -R $(whoami):admin /usr/local
> sudo chmod -R g+w /usr/local

> brew install caskroom/cask/brew-cask
> brew cask [list|cleanup|update|etc]
(gives error shown above)

Performed a complete homebrew uninstall, rm'ing extra dirs and files. Then complete homebrew re-install, followed by re-install many of the formulae I had previously.

Same commands above give same errors after reinstall.

Color me confused. 😕

Upvotes: 2

Views: 1691

Answers (1)

Buck3000
Buck3000

Reputation: 371

So I just resolved something similar - it was a permissions issue for me. I ended up running:

sudo chown -R $(whoami) your-directory-here

on the Cask and caskroom directories - you may have to look around a little bit to find those directories on your system.

Upvotes: -1

Related Questions