Rails 3: Passenger can't find git gems installed by bundler

杀马特。学长 韩版系。学妹 提交于 2019-11-28 02:53:59

Im used to have this problem, resolve using

bundle --deployment

Which will install the gems in vendor/bundle

Solution (took me a few hours):

Mare sure that RAILS_ROOT/.bundle/config (SetEnv etc. didn't work for me) contains:

--- 
BUNDLE_PATH: /home/xxxxx/.bundler

Note BUNDLE_PATH, not BUNDLER_PATH! There was also an DISABLED_SHARED_GEMS=1 entry, I removed it.

Then bundler recognises the correct path even when loaded from Passenger. Without Passenger, it always worked (and used /home/xxxxx/.bundler, as said in the question)

You can use bundle install --path vendor/bundle to install the gems locally, instead of into system gems.

If you want to keep using system gems, though, it's just one line in your Apache configuration to tell Passenger where to find your system gems:

SetEnv GEM_HOME /Users/bob/.bundle

There's a slightly more elaborate writeup on my blog at Using Passenger with GEM_HOME set

I ran into this problem while writing a Sinatra app. To solve it I added this line to config.ru.

require 'bundler/setup'

I had the same problem and it was due to a rights issue with RVM.

The user that run the web server can not check if GIT gem is available. As "Passenger" using the web user to run, it can not do this check.

The solution I found was to add web user to rvm group:

usermod -a -G rvm apache

I hope this will help some other people that don't want to have GEM deployed into "vendor/bundle".

I installed the passenger gem and its apache module as a sudo user and that was the problem in my case.

The reason why I used sudo initially was that I copied the code from railscasts' episode 122. Installing it without sodu access resolved this issue. Since Ruby was installed using rvm without the sudo access on my system.

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