简体   繁体   中英

Error for command - rails server - cannot load such file — sqlite3/sqlite3_native (LoadError)

I apologize if this question is redundant but I haven't been able to fix my problem with the suggestions I have found on here and on other sites. I am new to Ruby,Rails and many concepts that seem to be important for getting everything installed and running correctly.

I am on a mac OS 10.9. What I have installed is: ruby 2.0.0, Rails 4.0.2, rubygems 1.8.25. I have followed Hartl tutorial exactly from the beginning up until the point where I first call rails server and then I receive this error message:

Macintosh-0025bce1e74a:first_app johns$ rails server

/Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.8/lib/sqlite3.rb:6:in require': cannot load such file -- sqlite3/sqlite3_native (LoadError) from /Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.8/lib/sqlite3.rb:6:in rescue in '

from /Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.8/lib/sqlite3.rb:2:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `each'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `block in require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `each'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.5.1/lib/bundler.rb:131:in `require'
from /Users/johns/Desktop/rails/first_app/config/application.rb:7:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:74:in `require'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:74:in `block in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

I had installed sqlite3 prior to starting the rails tutorial so I thought perhaps that could possibly be related to the problem but I am not educated about paths and how to figure out if that is the problem.

Macintosh-0025bce1e74a:~ johns$ sqlite3 --version 3.7.13

From what I have read my computer will go through PATH to find the executable binaries needed to run a program and my PATH is as follows:

Macintosh-0025bce1e74a:~ johns$ echo $PATH /usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin

my gemfile is

source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0

gem 'rails', '4.0.2'

group :development do
  gem 'sqlite3', '1.3.8'
end

gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'

group :doc do
  gem 'sdoc', '0.3.20', require: false
end

I did remember to run bundle update, bundle install.

Thanks so much for any help!

EDIT I think I got it working by finally understanding how to perform the steps laid out in a link someone posted in a previous question of this nature

http://ahmedemad.wordpress.com/2013/05/17/ruby-on-rails-install-run-error/

EDIT It didn't work, the rails server command went through okay but when I tried to pull up the page I got another error:

undefined method `busy_timeout' for #SQLite3::Database:0x007fccb3e10438>

EDIT I tried another suggestion I found but it produced the same error when I tried to visit the site.

I edited the /sqlite3-1.3.8.gemspec and changed s.require_paths=["lib"] to s.require_paths= ["lib/sqlite3_native"] which apparently did the trick for some one.

EDIT got rvm and reinstalled things, had another go at it and it now works...weird

I find it interesting that this error is exactly the same as this: Repairing Rails and Server and on Nitrous.io

The answer suggests simply reinstalling rails by running:

gem install rails

And then bundle install in your project's directory to make sure everything's up to date.

If you install sqlite3 from source. You should enable the option SQLITE_ENABLE_COLUMN_METADATA at the configure time.

./configure CPPFLAGS='-DSQLITE_ENABLE_COLUMN_METADATA' CFLAGS='-DSQLITE_ENABLE_COLUMN_METADATA'

Also see here.

https://github.com/sparklemotion/sqlite3-ruby

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM