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?

junique
  • 901
  • 1
  • 10
  • 11
  • Isn't this a better candidate for `serverfault` since it deals with setting up `nginx` or `apache`? – alternative Aug 31 '10 at 00:35
  • I don't understand. I have the problems with Passenger, using Apache. – junique Aug 31 '10 at 00:50
  • 1
    `bundle pack` solve my problem. http://stackoverflow.com/questions/2494399/deploying-rails3-apps-with-bundler-and-phusion-passenger-bundle-dir-not-found – zires Apr 19 '12 at 03:16

6 Answers6

71

Im used to have this problem, resolve using

bundle --deployment

Which will install the gems in vendor/bundle

Roberto
  • 1,089
  • 1
  • 9
  • 13
  • 1
    This works perfectly, thanks. The docs say it [shouldn't be used for development](http://gembundler.com/bundle_install.html) though, so on a development machine you would use `bundle install --path vendor/bundle` instead. – Dave James Miller Dec 06 '11 at 11:43
  • 4
    I don't want my gems in my git repository. – docwhat Feb 17 '12 at 20:55
  • 5
    "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..." http://stackoverflow.com/questions/3681329/rails-3s-bundle-install-and-bundle-install-deployment-both-work-well-exce/3681411#3681411 – Peter Ehrlich Jun 04 '12 at 15:35
  • `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`? –  Mar 12 '13 at 05:45
  • @TheDoctorWhat That's what `.gitignore` is for. – briangonzalez Mar 03 '14 at 04:44
  • This is no longer recommended. https://stackoverflow.com/questions/3681329/rails-3s-bundle-install-and-bundle-install-deployment-both-work-well-exce/3681411#3681411 – linesarefuzzy Jun 23 '15 at 21:04
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)

junique
  • 901
  • 1
  • 10
  • 11
  • And mine! Thanks a lot. I left DISABLED_SHARED_GEMS=1 in place btw. – artemave Jan 18 '11 at 10:40
  • 1
    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. – davemyron Jan 26 '11 at 08:38
  • 1
    @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 process – HappyDeveloper Feb 22 '12 at 21:13
  • has this changed? I dont see the .bundle directory in my setup – jumpa May 09 '13 at 18:56
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

indirect
  • 3,470
  • 2
  • 25
  • 13
4

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

require 'bundler/setup'
declan
  • 5,605
  • 3
  • 39
  • 43
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".

Code-Source
  • 2,215
  • 19
  • 13
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.

VPaul
  • 1,005
  • 11
  • 21