Rails 3: Passenger can't find git gems installed by bundler
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'
Related videos on Youtube
junique
Updated on September 22, 2020Comments
-
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 bybundler 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 almost 14 yearsIsn't this a better candidate for
serverfault
since it deals with setting upnginx
orapache
? -
junique almost 14 yearsI don't understand. I have the problems with Passenger, using Apache.
-
zires about 12 years
bundle pack
solve my problem. stackoverflow.com/questions/2494399/…
-
Fábio Batista over 13 yearsSaved my day! Thanks for sharing.
-
artemave over 13 yearsAnd mine! Thanks a lot. I left DISABLED_SHARED_GEMS=1 in place btw.
-
davemyron over 13 yearsI 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 about 13 yearsvendoring my gems didn't work for me using passenger/nginx :(
-
Dave James Miller over 12 yearsThis 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 over 12 yearsI don't want my gems in my git repository.
-
docwhat over 12 yearsI don't want my gems in my git repository.
-
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 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 about 11 years
bundle --deployment
fails for me when installingnokogiri
(I am using Bitnami Rubystack so every time I installnokogiri
I pass the xml2 and xml2-include directories explicitly, how do I pass those arguments tobundle --deployment
? -
jumpa about 11 yearshas this changed? I dont see the .bundle directory in my setup
-
briangonzalez about 10 years@TheDoctorWhat That's what
.gitignore
is for. -
linesarefuzzy almost 9 yearsThis is no longer recommended. stackoverflow.com/questions/3681329/…