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

6

47

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 & accessing 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?

Ocher answered 31/8, 2010 at 0:33 Comment(3)
Isn't this a better candidate for serverfault since it deals with setting up nginx or apache?Embellish
I don't understand. I have the problems with Passenger, using Apache.Ocher
bundle pack solve my problem. #2494899Outspread
O
22

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)

Ocher answered 31/8, 2010 at 1:40 Comment(4)
And mine! Thanks a lot. I left DISABLED_SHARED_GEMS=1 in place btw.Ytterbium
I didn't have a .bundler directory in my home before adding the config option to .bundle/config and then re-running bundle install. After I did that, I had the directory and passenger was able to find the bundled gems.Maldonado
@orangechicken Thanks! that worked for me. Only detail is that I had to create the folder in the home folder of the user that is running the server processJailer
has this changed? I dont see the .bundle directory in my setupTetzel
A
71

Im used to have this problem, resolve using

bundle --deployment

Which will install the gems in vendor/bundle

Ajaajaccio answered 15/2, 2011 at 3:50 Comment(6)
This works perfectly, thanks. The docs say it shouldn't be used for development though, so on a development machine you would use bundle install --path vendor/bundle instead.Tribal
I don't want my gems in my git repository.Alloy
"When you use the --deployment flag, Bundler makes sure that every gem you need is vendored i.e. they are copied to a predetermined place your application's folder structure (which happens to be vendor/bundle in Rails by convention) This is good for two things..." #3681829Dasilva
bundle --deployment fails for me when installing nokogiri (I am using Bitnami Rubystack so every time I install nokogiri I pass the xml2 and xml2-include directories explicitly, how do I pass those arguments to bundle --deployment?Vorster
@TheDoctorWhat That's what .gitignore is for.Coltoncoltsfoot
This is no longer recommended. #3681829Hawkeyed
O
22

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)

Ocher answered 31/8, 2010 at 1:40 Comment(4)
And mine! Thanks a lot. I left DISABLED_SHARED_GEMS=1 in place btw.Ytterbium
I didn't have a .bundler directory in my home before adding the config option to .bundle/config and then re-running bundle install. After I did that, I had the directory and passenger was able to find the bundled gems.Maldonado
@orangechicken Thanks! that worked for me. Only detail is that I had to create the folder in the home folder of the user that is running the server processJailer
has this changed? I dont see the .bundle directory in my setupTetzel
I
8

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

Isotope answered 8/4, 2011 at 1:3 Comment(2)
vendoring my gems didn't work for me using passenger/nginx :(Macilroy
I don't want my gems in my git repository.Alloy
M
4

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

require 'bundler/setup'
Magalimagallanes answered 27/2, 2012 at 1:54 Comment(0)
V
0

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".

Veiled answered 16/7, 2013 at 21:52 Comment(0)
F
0

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.

Farci answered 21/9, 2018 at 12:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.