0

I want to setup a RoR server with Apache2 + Passenger3 + RVM, These are my configurations

# Passenger Apache Integartion
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.8.7-p352@global/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.8.7-p352@global/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.8.7-p352@global/ruby

and here is my .rvmrc

if [[ -s "/usr/local/rvm/gems/ruby-1.8.7-p352@myapp" ]] ; then
  . "/usr/local/rvm/gems/ruby-1.8.7-p352@myapp"
else
  rvm --create use  "1.8.7@myapp"
fi

myapp gemset is created and contains all required gems, so now in environment.rb file i load a gem file require require 'postmark-rails' And it is showing the error no such file to load -- postmark-rails (MissingSourceFile) Means it is not loading the proper gemset. How to figure it out?

1 Answers1

0

The .rvmrc file was not working well. So i searched out and find the proper way to create the .rvmrc file.

in the directory home used this command rvm 1.8.7@myapp --rvmrc --create

This create the proper .rvmrc file. Then put this code in config/setup_load_paths.rb for Rails 2 app

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
    # RVM is unavailable at this point.
    raise "RVM ruby lib is currently unavailable."
  end
end

and For Rails 3

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
    # RVM is unavailable at this point.
    raise "RVM ruby lib is currently unavailable."
  end
end

# If we're using a Bundler 1.0 beta
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'

# Or Bundler 0.9...
if File.exist?(".bundle/environment.rb")
  require '.bundle/environment'
else
  require 'rubygems'
  require 'bundler'
  Bundler.setup
end

The code is taken from http://blog.ninjahideout.com/posts/the-path-to-better-rvm-and-passenger-integration. It solved my the problem and the passenger is working very well with rvm.