I have shifted to ree using rvm by:
rvm use ree@mygemset
and installed kaminari gem through Gemfile and bundle install.
But Phusion passenger seems to still look for the gem in system default directory. It says:
Error message:
Could not find kaminari-0.10.4 in any of the sources (Bundler::GemNotFound)
What do I missing? Rails need any specific configuration to recognize the current ruby version and gemset I am using??
You need to instruct Passenger to load RVM and then setup the environment for your gemset. The easiest way to go about this involves three steps:
Create a .rvmrc
file: In the root of your rails project, create a file called .rvmrc
that contains the RVM command you would use to load up your gemset. For example:
rvm use ree@gemset
Trust the .rvmrc
file: Once you've deployed your new .rvmrc
file to your server, change directories into your rails project. RVM should ask you if you want to trust your .rvmrc
file; simply follow the instructions and type yes
when asked. If the prompt does not appear, use the following command to trust your .rvmrc
:
rvm rvmrc trust
Note: If you wish to automatically trust all .rvmrc
s, it is a simple matter of adding:
rvm_trust_rvmrcs_flag=1
to your personal or system wide rvmrc (~/.rvmrc
and /etc/rvmrc
, respectively).
Instruct passenger to set up the RVM environment: Instruct passenger to load up RVM and use the gemset in your .rvmrc
file by creating a new file in your Rails config
directory called setup_load_paths.rb
(so config/setup_load_paths.rb
in all). The file should contain the contents of https://gist.github.com/870310:
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
# This assumes Bundler 1.0+
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'
Now when you restart your app (touch tmp/restart.txt
) you should be good to go.
You should note that Passenger can only run one version of Ruby at a time; if Passenger was set up under something other than ree, you will probably have to reinstall Passenger and/or redo the wrapper script it generates.
Just an additional note to step3 of the Marked (Broandon's) answer, because I didn't get my Passenger3 up and run by using those codes.
The error message is as below:
*** Phusion Passenger: no passenger_native_support.bundle found for the current Ruby interpreter. Compiling one...
# mkdir -p /Users/jerry/.rvm/gems/ruby-1.9.3-p194@xxx/gems/passenger-3.0.18/ext/ruby/ruby-1.9.3-x86_64-macosx
# cd /Users/jerry/.rvm/gems/ruby-1.9.3-p194@xxx/gems/passenger-3.0.18/ext/ruby/ruby-1.9.3-x86_64-macosx
Unable to locate the RVM path. Your RVM installation is probably too old. Please update it with 'rvm get head && rvm reload && rvm repair all'.
Referring to the message "Unable to locate the RVM path", I checked the RVM Documentation
https://rvm.io/integration/passenger/
Edit config/setup_load_paths.rb to this:
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
gems_path = ENV['MY_RUBY_HOME'].split(/@/)[0].sub(/rubies/,'gems')
ENV['GEM_PATH'] = "#{gems_path}:#{gems_path}@global"
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
raise "RVM gem is currently unavailable."
end
end
# If you're not using Bundler at all, remove lines bellow
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'
Problem solved!
I followed the suggested answer and it moved me forward but then I got an error message:
RVM - Ruby integration was extracted to a separate gem, it should be installed by default >with RVM, remove the $LOAD_PATH.unshift
line and all should be fine again.
Visit https://rvm.io/integration/passenger for more details. (RuntimeError)
Passenger now have a gem. My mistake was not installing it in the ruby version and gemset I was using. Once I did that - everything worked sweet.
Remove the config/setup_load_paths.rb
file for Passenger 4. It is not needed.