MissingSourceFile: no such file to load -- sqlite3/database

J

João Macaíba

Hi,

I'm using active_record and sqlite3-ruby (gem) modules. When I try to
connect to sqlite3 database, I get a error :

"MissingSourceFile: no such file to load -- sqlite3/database"

I have "sqlite3/database.rb" in my $: path as shown below.

Does anyone know what this means or what causes it ?

My environment is :

- ruby 1.8.7 (2008-08-08 patchlevel 71) [i686-linux]
- gem 1.2.0

[gems]
- activerecord (2.1.0)
- activesupport (2.1.0)
- sqlite3-ruby (1.2.2)

Thanks in advance for any help.

Below are shown the steps of how this error occurs and some information
about database and RUBYLIB.

--- snip ---
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'active_record'
=> true
irb(main):003:0> ActiveRecord::Base.establish_connection({:adapter =>
'sqlite3', :dbfile => '../../db/per.db'})
=> #<ActiveRecord::Base::ConnectionSpecification:0xb781bb60
@adapter_method="sqlite3_connection",
@config={:dbfile=>"../../db/per.db", :adapter=>"sqlite3"}>
irb(main):004:0> class Per_Configuration < ActiveRecord::Base
irb(main):005:1> end
=> nil
irb(main):006:0> pc = Per_Configuration.find(1)
MissingSourceFile: no such file to load -- sqlite3/database
from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
`gem_original_require'
from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `require'
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in
`require'
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in
`new_constants_in'
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in
`require'
from
/usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.2/lib/sqlite3.rb:1
from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in
`gem_original_require'
from
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `require'
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in
`require'
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in
`new_constants_in'
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in
`require'
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/kernel/requires.rb:7:in
`require_library_or_gem'
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/kernel/reporting.rb:11:in
`silence_warnings'
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/kernel/requires.rb:5:in
`require_library_or_gem'
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:10:in
`sqlite3_connection'
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:292:in
`send'
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:292:in
`connection='
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:260:in
`retrieve_connection'
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in
`connection'
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2693:in
`quoted_table_name'
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1371:in
`find_one'
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1362:in
`find_from_ids'
from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:537:in
`find'
from (irb):6
from :0irb(main):007:0>
--- snip ---

--- snip ---
sqlite3 ../../db/per.db
SQLite version 3.4.2
Enter ".help" for instructions
sqlite> select * from Per_Configurations;
1|Ports_Dir|/usr/per|text
2|Buffer_Repositories|buffer/repositories|text
sqlite>
--- snip ---



--- snip ---
irb(main):007:0> $:.each do |path|
irb(main):008:1* puts path
irb(main):009:1> end
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/vendor/tzinfo-0.3.8
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/vendor/memcache-client-1.5.0
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/vendor/xml-simple-1.0.11
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/vendor/builder-2.1.2
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib
/var/lib/gems/1.8/gems/sqlite3-ruby-1.2.2/lib
/home/macaiba/development/projects/per/lib
/lib
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/bin
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/bin
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib
/usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.2/bin
/usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.2/lib
/usr/local/lib/ruby/site_ruby/1.8
/usr/local/lib/ruby/site_ruby/1.8/i686-linux
/usr/local/lib/ruby/site_ruby
/usr/local/lib/ruby/vendor_ruby/1.8
/usr/local/lib/ruby/vendor_ruby/1.8/i686-linux
/usr/local/lib/ruby/vendor_ruby
/usr/local/lib/ruby/1.8
/usr/local/lib/ruby/1.8/i686-linux
 
J

Jos Backus

Hi,

I'm using active_record and sqlite3-ruby (gem) modules. When I try to
connect to sqlite3 database, I get a error :

"MissingSourceFile: no such file to load -- sqlite3/database"

I have "sqlite3/database.rb" in my $: path as shown below.

Does anyone know what this means or what causes it ?

Try the advice given here:

http://wuhai.wordpress.com/2008/07/06/no-such-file-to-load---sqlite3database/

It would be REALLY nice if the maintainers would release 1.2.3 with a fix.
 
D

David Masover

Try the advice given here:
http://wuhai.wordpress.com/2008/07/06/no-such-file-to-load---sqlite3database/

"Sorry, no posts matched your criteria."
It would be REALLY nice if the maintainers would release 1.2.3 with a fix.

True. Or anything, really -- this is damned sloppy.

I'm seriously considering Amalgalite (spelling?), just because it seems
actively maintained.

Short answer: The permissions on that file are wrong. They're wrong in the
gem. You'll have to fix them manually.
 
J

Jos Backus

//wuhai.wordpress.com/2008/07/06/no-such-file-to-load---sqlite3database/[/url]

"Sorry, no posts matched your criteria."

Hey, it worked right before I posted it. :)

Glad to hear 1.2.3 has been released.
 
J

João Macaíba

Jos said:

About the changes on "ruby.h", they already there under ruby 1.8.7.

But, shame on me, I have not realized the missing 'r' permission for
'others':

--- snip ---
-rw-rw--w- 1 root root 24774 2008-08-26 18:54 database.rb
--- snip ---

Changing this permission as suggested in the link, have solved the
problem :)
It would be REALLY nice if the maintainers would release 1.2.3 with a fix.

Thanks for the help/time, Jos !

Regards,
João Macaíba.
 
J

João Macaíba

Erik said:
Are you sure you've read access on the file?

gegroet,
Erik V.
I haven't had:

--- snip ---
-rw-rw--w- 1 root root 24774 2008-08-26 18:54 database.rb
--- snip ---

I've corrected that :)

Regards,
João Macaíba.
 
J

Jos Backus

Thanks for the help/time, Jos !

Welcome. But 1.2.3 doesn't run out of the box either, at least on CentOS 5 with
the stock Ruby 1.8.5.

/usr/bin/ruby: symbol lookup error:
/usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.3/lib/sqlite3_api.so:
undefined symbol: RSTRING_PTR

$ nm sqlite3_api.so | grep RSTRING
U RSTRING_LEN
U RSTRING_PTR

http://github.com/jamis/sqlite3-ruby/commit/b3bdabfd82b2abca0898bca3ee690e5987744cd2
says it fixes linking against Ruby 1.8.5 but the sqlite3_api_wrap.c generated
by swig (from extconf.rb) defines the necessary RSTRING_* macros too late in
the generated code. Moving the defines up in the generated file works around
the problem, but I'm not sure what the right fix is as the defines already sit
at the top of the sqlite3_api.i file.
 
J

Jos Backus

http://github.com/jamis/sqlite3-ruby/commit/b3bdabfd82b2abca0898bca3ee690e5987744cd2
says it fixes linking against Ruby 1.8.5 but the sqlite3_api_wrap.c generated
by swig (from extconf.rb) defines the necessary RSTRING_* macros too late in
the generated code. Moving the defines up in the generated file works around
the problem, but I'm not sure what the right fix is as the defines already sit
at the top of the sqlite3_api.i file.

Not sure how I came up with this but it's incorrect. Regenerating the
sqlite3_api_wrap.c file (as extconf.rb does, using `swig -ruby sqlite3_api.i')
fixes the issue. 1.2.4 has the regenerated sqlite3_api_wrap.c.

Thanks again Jamis.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top