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

28,208

Solution 1

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)

Solution 2

Im used to have this problem, resolve using

bundle --deployment

Which will install the gems in vendor/bundle

Solution 3

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

Solution 4

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

require 'bundler/setup'
Share:
28,208

Related videos on Youtube

junique
Author by

junique

Updated on September 22, 2020

Comments

  • junique
    junique over 3 years

    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?

    • alternative
      alternative almost 14 years
      Isn't this a better candidate for serverfault since it deals with setting up nginx or apache?
    • junique
      junique almost 14 years
      I don't understand. I have the problems with Passenger, using Apache.
    • zires
      zires about 12 years
      bundle pack solve my problem. stackoverflow.com/questions/2494399/…
  • Fábio Batista
    Fábio Batista over 13 years
    Saved my day! Thanks for sharing.
  • artemave
    artemave over 13 years
    And mine! Thanks a lot. I left DISABLED_SHARED_GEMS=1 in place btw.
  • davemyron
    davemyron over 13 years
    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.
  • Macario
    Macario about 13 years
    vendoring my gems didn't work for me using passenger/nginx :(
  • Dave James Miller
    Dave James Miller over 12 years
    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.
  • docwhat
    docwhat over 12 years
    I don't want my gems in my git repository.
  • docwhat
    docwhat over 12 years
    I don't want my gems in my git repository.
  • HappyDeveloper
    HappyDeveloper over 12 years
    @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
  • Peter Ehrlich
    Peter Ehrlich almost 12 years
    "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..." stackoverflow.com/questions/3681329/…
  • Admin
    Admin about 11 years
    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?
  • jumpa
    jumpa about 11 years
    has this changed? I dont see the .bundle directory in my setup
  • briangonzalez
    briangonzalez about 10 years
    @TheDoctorWhat That's what .gitignore is for.
  • linesarefuzzy
    linesarefuzzy almost 9 years
    This is no longer recommended. stackoverflow.com/questions/3681329/…