Load custom library path

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

Next, I tried adding “$LOAD_PATH.unshift ‘$HOME/gem/lib’” to
environment.rb without any luck.

Does anyone have any ideas?


On Mon, Oct 26, 2009 at 2:29 AM, nic [email protected] wrote:

through Passenger. Passenger still detects the old (system-wide)

Nic, you can do one of the following:

Option 1:

  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:

  1. use rake locally to unpack the gems into vendor/gems

    rake gems:unpack

    Note: This requires that the dependent gems are listed in the
    and you can read that file to see how it’s done or watch

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

  1. install the gemcutter gem (locally)

  2. install the bundler gem (locally)

    Note: You can find more information about the usage at the


Finally, you usually can add gems to the load path by doing the
within your

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’ )

Option 3: using a combination of Option (1) and (2).

Good luck,


I think you may have misunderstood my problem. The issue is not that I
need a newer version of a certain gem, but rather that I need a new
version of RubyGems itself. My app craps out at line 90 of boot.rb,
which looks like this:

84        def load_rubygems
85          min_version = '1.3.2'
86          $stderr.puts $:.inspect
87          require 'rubygems'
88          unless rubygems_version >= min_version
89            $stderr.puts %Q(Rails requires RubyGems >= #

{min_version} (you have #{rubygems_version}). Please gem update -- system and try again.)
90 exit 1
91 end

I added line 86, btw, to check the value of $:. This is the output I
get in my error log:

["/home/ncolgan/gem/lib", “/root/passenger-2.1.1/lib”, “/root/
passenger-2.1.1/ext”, “/usr/lib64/ruby/gems/1.8/gems/fastthread-1.0.7/
bin”, “/usr/lib64/ruby/gems/1.8/gems/fastthread-1.0.7/lib”, “/usr/
lib64/ruby/gems/1.8/gems/fastthread-1.0.7/ext”, “/usr/lib64/ruby/
site_ruby/1.8”, “/usr/lib64/ruby/site_ruby/1.8/x86_64-linux”, “/usr/
lib64/ruby/site_ruby”, “/usr/lib64/ruby/1.8”, “/usr/lib64/ruby/1.8/
x86_64-linux”, “.”]
Rails requires RubyGems >= 1.3.2 (you have 1.3.1). Please gem update --system and try again.

As you can see, my directory (/home/ncolgan/gem/lib) WAS added to $:
but the new version of RubyGems (1.3.5) located in that directory
wasn’t detected.

Any help is appreciated.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs