`bundle install` failed due to permission denied

JoJoS picture JoJoS · Jul 31, 2013 · Viewed 30.2k times · Source

I've installed bundler gem on my new server and when I try to execute bundle install, it failed with this error :

Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/usr/lib/ruby/1.9.1/fileutils.rb:247:in `mkdir': Permission denied - /var/lib/gems (Errno::EACCES)

My server is a Debian wheezy (7.1) with default ruby 1.9.3 package installed. I have configured /etc/gemrc like this : gem: --user-install to allow users install gems locally.

The bundler gem was installed inside my user's gems dir ~/.gem like i want with this command : gem install bundler (no sudo). But bundler want install gems into /var/lib/gems instead my gems directory :(

I don't understand what's wrong with bundler... Why it doesn't try to install gem where I want (in my gems local dir) ?

ps: in my laptop, with archlinux and default ruby 2.0.0 package installed, I have no problems with bundler to install user's gems.

Answer

JoJoS picture JoJoS · Aug 21, 2013

I found !

I had updated my rubygem like this gem update --system. But only my local gems were update due to the gem: --user-install restriction in my /etc/.gemrc. When bundler works, it use the global rubygem and not mine.

To fixe this issue, I updated the global rubygems with : sudo gem update --system --no-user-install.

And all works fine !