`bundle install` failed due to permission denied

╄→尐↘猪︶ㄣ 提交于 2019-12-09 04:20:48

问题


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.


回答1:


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 !




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/17959435/bundle-install-failed-due-to-permission-denied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!