Friday, August 24, 2012

The given ruby environment requires system (RVM::IncompatibleRubyError)

Here's another Passenger error I wanted to share. I had a hard time while searching for this error:
Exception PhusionPassenger::UnknownError in PhusionPassenger::ClassicRails::ApplicationSpawner (The given ruby environment requires system (versus ruby-x.x.x-pxxx) (RVM::IncompatibleRubyError))
It took changing my .rvmrc file from this:
rvm ruby-x.x.x-pxxx@rails3x
view raw .rvmrc hosted with ❤ by GitHub
...to this:
if [[ -s "/usr/local/rvm/environments/ruby-x.x.x-pxxx@rails3x" ]] ; then
. "/usr/local/rvm/environments/ruby-x.x.x-pxxx@rails3x"
else
rvm --create use "ruby-x.x.x-pxxx@rails3x"
fi
view raw .rvmrc hosted with ❤ by GitHub
I believe the error occurred as the result of an RVM update, where some necessary changes were already made, but feel free to comment if this doesn't fix the error for you, and I'll sure I can help. UPDATE: here are a few other things to check if you're still getting errors: 1. You may need to setup some load paths. We just added a file under config called setup_load_paths.rb. Notice that we commented out the unshift at some point.
begin
rvm_path = File.dirname(File.dirname('path/to/rvm/rubies/ruby-x.x.x-pxxx'))
rvm_lib_path = File.join(rvm_path, 'lib')
# $LOAD_PATH.unshift rvm_lib_path
require 'rvm'
module RVM
class Environment
#Converts a ruby identifier (string + gemset) to just the ruby string.
def self.identifier_to_ruby_string(identifier)
return "ruby-x.x.x-pxxx"
end
end
end
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
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'
2. Check that the following lines are in your config/deploy.rb. Again, we later commented out a line due to upgrades.
# $:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path. # commented out to fix upgrade
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_ruby_string, 'ruby-x.x.x-pxxx@rails3x' # Or whatever rvm environment you want it to run in.
set :rvm_bin_path, "/path/to/rvm/bin"
set :rvm_type, :system
view raw deploy.rb hosted with ❤ by GitHub
As always, please let me know how this works out for you.

No comments:

Post a Comment