I’m trying to use a rails app that uses a newer version of RubyGems
than my host provides. Since I don’t have root access, I decided to
try to install my own version of gems in my home directory. I did so
by downloading the package and running the install using "ruby
setup.rb --prefix=$HOME/gem". Then I added “$HOME/gem/bin” to my $PATH
and “$HOME/gem/lib” (the location of my new rubygems.rb) to $RUBYLIB.
Now, this works fine when I test it with the webrick server (using
script/server), but I get an error when trying to run it proper
through Passenger. Passenger still detects the old (system-wide)
version of RubyGems instead of my newly added version in my home
directory.
Next, I tried adding “$LOAD_PATH.unshift ‘$HOME/gem/lib’” to
environment.rb without any luck.
Does anyone have any ideas?
Thanks,
nic.
Nic, you can do one of the following:
Option 1:
- ask the host to install the gems that your application requires
Option 2: get a better host account that allows better access
Option 3:
- use rake locally to unpack the gems into vendor/gems
rake gems:unpack
Note: This requires that the dependent gems are listed in the environment.rb
and you can read that file to see how it’s done or watch any railscasts.com
screencast.
- upload the vendor/gems to the remote server
Note: This may not work if your application requires native gems because the local
OS may be different from the remote OS.
Option 4: use the bundler gem
-
install the gemcutter gem (locally)
-
install the bundler gem (locally)
Note: You can find more information about the usage at the following site:
http://github.com/wycats/bundler
Finally, you usually can add gems to the load path by doing the following within your
environment.rb:
Option 1: add gems using less ruby code within the environment.rb file
Add additional load paths for your own custom dirs
config.load_paths += %W( #{RAILS_ROOT}/extras )
Option 2: add gems using more ruby code within the environment.rb file
Dir.glob( File.expand_path( “#{RAILS_ROOT}/vendor/gems/*”, FILE) ).each do | gem |
$:.unshift File.join( gem, 'lib' )
end
Option 3: using a combination of Option (1) and (2).
Good luck,
-Conrad