Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`bundle install` failed due to permission denied

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.

like image 734
JoJoS Avatar asked Jul 30 '13 23:07

JoJoS


People also ask

What is bundle installation?

bundle install is a command we use to install the dependencies specified in your Gemfile.

What is the difference between bundle and bundle install?

The commands bundle & bundle install also have the same functionality. bundle uses Thor, and bundle 's default task is install . Also, bundle i does the same thing as bundle install because bundle 's task i is mapped (aliased) to install .


3 Answers

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 !

like image 162
JoJoS Avatar answered Oct 23 '22 21:10

JoJoS


According to bundler documentation, a $BUNDLE_PATH or $GEM_HOME env variable can be set to make it the default writeable place.

export BUNDLE_PATH=~/.gems

bundle install

It is pretty handy if you {do not have/do not want to use} root access.

like image 34
Oncle Tom Avatar answered Oct 23 '22 20:10

Oncle Tom


bundle install does not use the gemrc settings. (Although possibly that has changed in a recent update, but the update appears to load ~/.gemrc only, not /etc/gemrc)

You can do what you want with bundle install --path ~/.gem

However, I would highly recommend getting rbenv or RVM working. You said that you had the "same result" with rbenv. If your gems were trying to install into /var/lib/gems when you had rbenv installed, then it wasn't an rbenv-installed Ruby that was running that command. Either rbenv was still using the system Ruby (which it will until you pick an rbenv installed Ruby to become the default), or you did not have rbenv running correctly.

like image 12
Legion Avatar answered Oct 23 '22 21:10

Legion