I seem to never remember the steps for this procedure (and I’ve needed it a few times already), so I figured I would just write it down here for future reference.
We need to give instructions to passenger to load up the right gemset in our application’s directory.
.rvmrc file
Create an .rvmrc file in the web application’s root directory:
[color-box]> touch .rvmrc[/color-box]
Create a new gemset
[color-box]> rvm gemset create example[/color-box]
Edit the .rvmrc file and add the gemset to be used, aswell as the ruby version needed for it
[color-box]> echo “rvm use 1.9.2@example” >> .rvmrc[/color-box]
Trust the .rvmrc file
[color-box]> rvm rvmrc trust[/color-box]
Passenger
Passenger doesn’t know about our project-specific gems whereabouts so we need to give it an access path to locate them. In order to do this, we create a new file called setup_load_paths.rb in the config folder of the application like so:
[color-box]> touch config/setup_load_paths.rb[/color-box]
Paste the following into the newly create file:
[color-box]if ENV[‘MY_RUBY_HOME’] && ENV[‘MY_RUBY_HOME’].include?(‘rvm’)
begin
rvm_path = File.dirname(File.dirname(ENV[‘MY_RUBY_HOME’]))
rvm_lib_path = File.join(rvm_path, ‘lib’)
$LOAD_PATH.unshift rvm_lib_path
require ‘rvm’
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
raise “RVM ruby lib is currently unavailable.”
end
end[/color-box]
Restart the server and we’re done.
[color-box]> touch tmp/restart.txt[/color-box]






