[BUG] Segmentation fault ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

I am using Active Record outside rails. I created one rb file at:


Code of process.rb


require ‘active_record’
:adapter => “mysql2”,
:host => “localhost”,
:username => “root”,
:password => “root123”,
:database => “testproject_development”

But when i run this rb file then i get the following error:-

[BUG] Segmentation fault ruby 1.8.7 (2011-06-30 patchlevel 352)

Any help will be highly appreciated.

:username => “root”,

You’ve got some sort of ruby version mixup here - you’ve got ruby 1.8.7
that is trying to load a native extension compiled for ruby 1.9. I’d
that is because your shebang is saying use /usr/bin/ruby, which is
presumably the system provided ruby, but dvm has setup the environment
variables that ruby uses to have it look for gems in the rvm copy of

I assume that you can’t change the way it is invoked (to ruby process.rb
rather than ./process.rb) but if you change the shebang to

#!/usr/bin/env ruby

that should pick up the rvm provided ruby, assuming that this script is
running in a context where rvm has been loaded.


Many Thanks Fred, It worked :slight_smile: