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

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
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:inrequire’
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:innew_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:ingem_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:inrequire’
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:inrequire’
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:insilence_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:insqlite3_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:inconnection=’
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:inconnection’
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:infind_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:infind’
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
.
— snip —

On Wed, Aug 27, 2008 at 12:11:05AM +0900, Joo Macaba wrote:

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.

Are you sure you’ve read access on the file?

gegroet,
Erik V.

On Tuesday 26 August 2008 11:10:37 Jos B. wrote:

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/

“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.

On Wed, Aug 27, 2008 at 01:30:36PM +0900, David M. wrote:

On Tuesday 26 August 2008 11:10:37 Jos B. wrote:
http://wuhai.wordpress.com/2008/07/06/no-such-file-to-load---sqlite3database/

“Sorry, no posts matched your criteria.”

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

Glad to hear 1.2.3 has been released.

On Tuesday 26 August 2008 23:34:37 Jeremy K. wrote:

Good news:

1.2.3 was just released!

Seems to be fixed – or at least, not broken. Thanks!

On Tue, Aug 26, 2008 at 9:30 PM, David M. [email protected]
wrote:

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.

Good news:

1.2.3 was just released!

jeremy

Erik V. wrote:

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 :slight_smile:

Regards,
João Macaíba.

On Wed, Aug 27, 2008 at 10:22:02PM +0900, Joo Macaba wrote:

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.

On Thu, Aug 28, 2008 at 06:45:18AM +0900, Jos B. wrote:

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.

Jos B. wrote:

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/

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 :slight_smile:

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.