Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
811 views
in Technique[技术] by (71.8m points)

ruby - no such file to load -- sqlite3/sqlite3_native

I am having trouble trying to run the following ruby script on OSX (Leopard).

    require 'sqlite3'
    database = SQLite3::Database.new( "new.database" )

    database.execute( "create table sample_table (id INTEGER PRIMARY KEY, sample_text TEXT, sample_number NUMERIC);" )

    database.execute( "insert into sample_table (sample_text,sample_number) values ('Sample Text1', 123)")
    database.execute( "insert into sample_table (sample_text,sample_number) values ('Sample Text2', 456)")

    rows = database.execute( "select * from sample_table" )

    p rows

but I get the following error:

/Users/Ted/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- sqlite3/sqlite3_native (LoadError)
    from /Users/Ted/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /Users/Ted/.rvm/gems/ruby-1.9.2-p180/gems/sqlite3-1.3.4/lib/sqlite3.rb:6:in `rescue in <top (required)>'
    from /Users/Ted/.rvm/gems/ruby-1.9.2-p180/gems/sqlite3-1.3.4/lib/sqlite3.rb:2:in `<top (required)>'
    from <internal:lib/rubygems/custom_require>:33:in `require'
    from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from sequelsample.rb:1:in `<main>'

How can I fix this issue? I have installed the following gems with the commands using ruby 1.9.2p180 (2011-02-18 revision 30909) [i386-darwin9.8.0]:

sudo gem install sqlite3-ruby -- --with-sqlite3-dir=/sw
sudo gem install sqlite3 -- --with-sqlite3-dir=/sw

sqlite3 (1.3.4)
sqlite3-ruby (1.3.3)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Fixed it with this commands:

  gem uninstall sqlite3
  gem uninstall sqlite3-ruby
  sudo gem install sqlite3 -- --with-sqlite3-dir=/sw

Ted


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...