Ruby-build: You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.

Created on 1 Jun 2012  Â·  12Comments  Â·  Source: rbenv/ruby-build

After installing via rbenv install

Most helpful comment

OK, so /Users/thees/.rbenv/shims is missing from your PATH, which leads me to believe that you need to complete your rbenv setup. You need to add this to your ~/.bash_profile (or ~/.zshrc if you're using zsh):

eval "$(rbenv init -)"

Then restart your shell (opening a new tab would do).

All 12 comments

I don’t remember what it was like when I installed rbenv and ruby-build, but I do know one thing that commonly trips me up with rbenv. Did you run rbenv rehash? I’m not sure if it’s necessary in this case, but it’s worth a try. You have to run it whenever you install something under rbenv that uses a native binary. If you install the gem rbenv-rehash, it will run rbenv rehash for you automatically in most cases.

And I think that that “write permissions” error can often be solved by prepending sudo to the command (and authorizing with the root password). But I don’t know if that would cause security problems or make ruby-build install under the wrong user.

I'm running into the same issue on a clean install (via homebrew) on Lion. Strangest thing is that it still tries to use 1.8 even though I'm on 1.9.

Are you sure you're hitting rbenv's gem shim and not the system gem binary?

Yeah, that's probably it. Strange path order in oh my zsh...

Sent from my iPhone

On 2012-12-18, at 8:09 PM, Sam Stephenson [email protected] wrote:

Are you sure you're hitting rbenv's gem shim and not the system gem binary?

—
Reply to this email directly or view it on GitHub.

You probably want to try "rbenv local " or "rbenv global ". It will put you in the ruby VERSION you want to install gems for.

how might one change the PATH in this case? Ran into this same problem after upgrading to Mavericks

If you look at:

$ echo $PATH | tr ':' $'\n'

If you've correctly set up rbenv, then ~/.rbenv/shims should be higher in the list than /usr/bin. Check which ruby/RubyGems executable will get run with these commands:

$ which -a ruby
$ which -a gem

You probably don't want /usr/bin/ruby or /usr/bin/gem being run, since they are what ships with Mavericks system and not a great fit for doing development with since they require sudo when installing new gems.

So I ran:

$ echo $PATH | tr ':' $'\n'

and got back:

/Users/thees/.rbenv/bin
/Applications/Postgres.app/Contents/MacOS/bin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin

in that order. However, when I enter

$ which ruby

I get

/usr/bin/ruby

Which is the bin for the native ruby on OSX. I think this is what's causing me to run into major "permission error"s with pretty much any change I try to make to gems, Ruby, or Rails.

OK, so /Users/thees/.rbenv/shims is missing from your PATH, which leads me to believe that you need to complete your rbenv setup. You need to add this to your ~/.bash_profile (or ~/.zshrc if you're using zsh):

eval "$(rbenv init -)"

Then restart your shell (opening a new tab would do).

That solved it. Thanks!

Hi @mislav , I have a similar issue.

$ gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

I have added

eval "$(rbenv init -)"

to .bash_profile, and if I run

$ echo $PATH | tr ':' $'\n'

I got

/Users/username/.rbenv/shims
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

So you can see I have rbenv/shims at the highest. But when I run

which -a ruby

I got

/usr/bin/ruby

and with

which -a gem

I got

/usr/bin/gem

I don't know why they are still running. I have also tried

rbenv local
rbenv global

which is suggested by other people. But the error remains. Do you have any idea on solving this?

Thank you in advance!

So, a quick solution which worked for me (OSX), might be helpful for others.
I installed ruby with $ rbenv install 2.5.3
$ rbenv local returned system
Next, I run rbenv local 2.5.3

Gem install worked after that

Was this page helpful?
0 / 5 - 0 ratings

Related issues

denisemauldin picture denisemauldin  Â·  4Comments

artoodeeto picture artoodeeto  Â·  4Comments

JDutil picture JDutil  Â·  3Comments

dpaluy picture dpaluy  Â·  6Comments

florentmorin picture florentmorin  Â·  5Comments