开发者

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

Rails 3.0.0, Passenger 2.2.15:

  • Create a new Rails project
  • Add gem 'paperclip', :git => 'git://github.com/lmumar/paperclip.git', :branch => 'rails3' to your Gemfile
  • Do bundle install
  • Everything OK, starting with rails/script server & a开发者_开发问答ccessing also works
  • However, when accessing with Passenger, it says:

git://github.com/lmumar/paperclip.git (at rails3) is not checked out. Please run bundle install (Bundler::GitError)

I have tried bundler pack (doesn't help) and setting BUNDER_HOME to ~/.bundler (the Paperclip git gets installed there by bundler install) in the .htaccess and various places in config/*.rb, but this wasn't successful, too.

~/.bundler is owned by the same user as the Rails project (Passenger runs under this user), so it can't be a permission problem. sudo is installed and called by bundle install.

Any hints?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜