ruby-on-railsrubycassandradatastax-ruby-driver

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- cassandra (LoadError)


Running Ruby class is ok by ruby1.8. but when I try to change the interpreter by updating the ruby configs:

sudo update-alternatives --config ruby

and select Ruby1.9 then I have this error every time I run my ruby class:

    /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:
in `require': cannot load such file -- cassandra (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'

A piece of class custom_require.rb is :

module Kernel

  if defined?(gem_original_require) then
    # Ruby ships with a custom_require, override its require
    remove_method :require
  else
    ##
    # The Kernel#require from before RubyGems was loaded.

    alias gem_original_require require
    private :gem_original_require
  end


  def require path
    if Gem.unresolved_deps.empty? or Gem.loaded_path? path then
    #!!!!!line 36 !!!!!:  
    gem_original_require path
    else
      spec = Gem::Specification.find { |s|
        s.activated? and s.contains_requirable_file? path
      }

I read that using RVM may solve the problem but actually I have no idea about how to manage it.

please give me an idea.


Solution

  • Rubygems are separated by ruby version, so you need to reinstall the Cassandra gem:

    gem install cassandra
    

    Make sure that gem is pointed to the 1.9 gem.

    The main reason you need to do this is to rebuild the C extensions against the 1.9 libraries.