1

I've just created a new amazon Linux instance and installed ruby 1.9.3 and rails 3.2.8.

Upon creating a new project I immediately receive failures due to sqlite3. The error is:

[root@xxxxx fun]# rails server
/usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
    from /usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:6:in `rescue in <top     (required)>'
    from /usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:2:in `<top     (required)>'

I have confirmed that sqlite3 is working just fine outside of rails (i.e. I successfully created a database, did inserts/reads using ruby code). Here is a quick show of loading sqlite3 in irb:

irb(main):001:0> require 'sqlite3'
=> true

I'm all up to date with bundle install. sqlite3 is at version 1.3.6

I have the following packages installed:

ruby19-1.9.3.0-7.17.amzn1.i686
ruby19-devel-1.9.3.0-7.17.amzn1.i686
ruby19-irb-1.9.3.0-7.17.amzn1.noarch
ruby19-libs-1.9.3.0-7.17.amzn1.i686
rubygem19-io-console-0.3-7.17.amzn1.i686
rubygem19-rdoc-3.9.4-7.17.amzn1.i686
rubygems19-1.8.11-7.17.amzn1.noarch
sqlite-3.6.20-1.8.amzn1.i686
sqlite-devel-3.6.20-1.8.amzn1.i686

Any ideas on what I could try to get things working? Thanks!

Update For "fun" I commented out the gem sqlite3 line from my Gemfile and tried "rails server" again. First it complained about not having a javascript runtime (which I could fix) but then it is getting the following. There seems to be something royally wrong with my install.

[root@xxxx fun]# rails server
/usr/local/share/gems/gems/railties-3.2.8/lib/rails/railtie/configuration.rb:85:in `method_missing': undefined method `active_record' for #<Rails::Application::Configuration:0x9e68f58> (NoMethodError)
    from /srv/rails/fun/config/application.rb:54:in `<class:Application>'
    from /srv/rails/fun/config/application.rb:13:in `<module:Fun>'
    from /srv/rails/fun/config/application.rb:12:in `<top (required)>'
krsyoung
  • 1,171
  • 1
  • 12
  • 24
  • Does this help: http://stackoverflow.com/questions/7604049/no-such-file-to-load-sqlite3-sqlite3-native ? – Sam Peacey Sep 02 '12 at 02:53
  • Thanks for the suggestion, I had a look at that post before and ruled it out. Just to be safe I tried the steps it suggested but I'm still seeing the same issue. – krsyoung Sep 02 '12 at 03:14
  • From what I gather, amazon linux uses yum package manager, what happens when you run the following: `yum install ruby-devel sqlite-devel`? – Sam Peacey Sep 02 '12 at 03:24
  • Yeah, this system is using yum. I checked for the packages and here is what I have installed (the ruby-devel pulls the 1.8.7 code). I updated the original post with the list of packages I have installed. Seems like all of the right stuff is there. I don't understand why a standalone ruby script works but rails croaks -- some type of load path issue? – krsyoung Sep 02 '12 at 03:54

1 Answers1

1

You may have a path problem.

To see if you have more than one version of Ruby, Rails, or gem installed:

find / | grep bin/ruby

    find / | grep bin/rails     find / | grep bin/gem

On Amazon servers, I typically keep the system Ruby as is, and install my own current Ruby by using the excellent ruby-build script (better than RVM, in my opinon).

https://github.com/sstephenson/ruby-build

If you do have more than one Ruby, I suggest that you set your environment to choose one, for example by using ruby-build or by setting your PATH in your .bashrc file or /etc/environment file something like this:

PATH=/opt/ruby/1.9.1-p134/bin;$PATH

If you're using RVM, I suggest you uninstall it and change to use ruby-build.

To uninstall RVM, I use this script:

https://github.com/SixArm/sixarm_unix_shell_scripts/blob/master/rvm-uninstall-danger
joelparkerhenderson
  • 34,808
  • 19
  • 98
  • 119
  • Thanks Joel! This did it (eventually). I had previously removed all traces of Ruby 1.8.7 so I only had 1.9.3 on the system (something in that process must have caused my issue). Today I uninstalled all gems, used ruby-build to install 1.9.1-p134 as a regular user and then reinstalled rails 3.2.8. I can now successfully create a new project and run it. Thanks a million for the suggestion! – krsyoung Sep 03 '12 at 04:44