Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Windows XP problem with Ruby, gem sqlite3-ruby, and SQLite3

Reply
Thread Tools

Windows XP problem with Ruby, gem sqlite3-ruby, and SQLite3

 
 
SunSw0rd
Guest
Posts: n/a
 
      07-01-2009
Varients of this problem have been posted before. However none of the
solutions have worked for me. Therefore I started with a clean slate.
(1) uninstalled and reinstalled Ruby (version 1.8.6) into standard
directory C:\Ruby using standard installer.
(2) Went to http://sqlite.org/download.html and downloaded
sqlite-3_6_16.zip and sqlitedll-3_6_16.zip to C:\SQLite. Extracted the
files there.
(3) Copied sqlite3.dll and sqlite3.exe to C:\Ruby\bin
(4) Launched a command window, went to C:\Ruby\bin, and executed: “gem
install sqlite3-ruby -v 1.2.3”
Results were positive:
===
C:\Ruby\bin>gem install sqlite3-ruby -v 1.2.3
Successfully installed sqlite3-ruby-1.2.3-x86-mswin32
1 gem installed
Installing ri documentation for sqlite3-ruby-1.2.3-x86-mswin32...
Installing RDoc documentation for sqlite3-ruby-1.2.3-x86-mswin32...
===

No problems detected so far. So I created a very simple script in C:
\Ruby\bin called sql1.rb:
===
require 'sqlite3'
db = SQLite3:atabase.new( "test.db" )
sql = <<SQL
create table the_table (
a varchar2(30),
b varchar2(30)
);

insert into the_table values ( 'one', 'two' );
insert into the_table values ( 'three', 'four' );
insert into the_table values ( 'five', 'six' );
SQL
db.execute_batch( sql )
db.execute( "select * from test" )
===

Result is this:
===
C:\Ruby\bin>ruby sql1.rb
../sqlite3.dll: 127: The specified procedure could not be found. -
Init_sqlite3 (LoadError)
../sqlite3.dll
from sql1.rb:2
===

Same error occurs if the only line in the Ruby script is the: require
'sqlite3'

Machine is an XP machine. Does not have a C:\windows\system32
directory but just in case there was some unknown hard coded
dependency I created that and copied the two sqlite files there
(the .dll and .exe). That did not fix the problem.

The problem is not that C:\Ruby\bin is not in the PATH variable, I
execute "set" and can see it right in the path.

Does anyone have any idea where the root cause of the problem might be?
 
Reply With Quote
 
 
 
 
SunSw0rd
Guest
Posts: n/a
 
      07-01-2009
A further symptom on this issue. When I execute irb I detect the
following:
===
C:\Ruby\bin>irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'sqlite3'
LoadError: 127: The specified procedure could not be found. -
Init_sqlite3
../sqlite3.dll
from ./sqlite3.dll
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
31:in `require'
from (irb):2
irb(main):003:0>
===

Is this saying there is something wrong with the downloaded sqlite3
DLL itself?
 
Reply With Quote
 
 
 
 
Michael Linfield
Guest
Posts: n/a
 
      07-01-2009
> Is this saying there is something wrong with the downloaded sqlite3
> DLL itself?


No, however...

I suggest reinstalling ruby... and since you're on Windows, use the
one-step installer package for Ruby 1.8.6

- Mac
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Luis Lavena
Guest
Posts: n/a
 
      07-02-2009
On Jul 1, 6:27*pm, SunSw0rd <(E-Mail Removed)> wrote:
> A further symptom on this issue. When I execute irb I detect the
> following:
> ===
> C:\Ruby\bin>irb
> irb(main):001:0> require 'rubygems'
> => true
> irb(main):002:0> require 'sqlite3'
> LoadError: 127: The specified procedure could not be found. * -
> Init_sqlite3
> ./sqlite3.dll
> * * * * from ./sqlite3.dll
> * * * * from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 31:in `require'
> * * * * from (irb):2
> irb(main):003:0>
> ===
>
> Is this saying there is something wrong with the downloaded sqlite3
> DLL itself?


No, the problem is Ruby itself.

C:\Users\Luis>irb
irb(main):001:0> require 'rbconfig'
=> true
irb(main):002:0> RbConfig::CONFIG['DLEXT']
=> "so"
irb(main):003:0> RbConfig::CONFIG['DLEXT2']
=> "dll"

DLEXT is used to identify Ruby C extensions.

Since you're CD'ing from Ruby\bin, it's finding 'sqlite3.dll' and
think it is an extension. See this:

C:\Users\Luis>cd Tools\bin

C:\Users\Luis\Tools\bin>dir sqlite*.*
Volume in drive C is Windows7
Volume Serial Number is 50BD-564E

Directory of C:\Users\Luis\Tools\bin

18/05/2009 01:40 p.m. 505.873 sqlite3.dll
21/05/2009 10:03 p.m. 520.574 sqlite3.exe
2 File(s) 1.026.447 bytes
0 Dir(s) 44.951.277.568 bytes free

C:\Users\Luis\Tools\bin>irb
irb(main):001:0> require 'sqlite3'
LoadError: 127: The specified procedure could not be found. -
Init_sqlite3
../sqlite3.dll
from ./sqlite3.dll
from (irb):1

Now, please try doing the require OUTSIDE Ruby\bin folder.

Also, since you installed sqlite3 as a gem, please require rubygems
first:

require 'rubygems'
require 'sqlite3'

HTH
--
Luis Lavena
 
Reply With Quote
 
SunSw0rd
Guest
Posts: n/a
 
      07-02-2009
On Jul 1, 10:52*pm, Luis Lavena <(E-Mail Removed)> wrote:
> On Jul 1, 6:27*pm, SunSw0rd <(E-Mail Removed)> wrote:
>
>
>
> > A further symptom on this issue. When I execute irb I detect the
> > following:
> > ===
> > C:\Ruby\bin>irb
> > irb(main):001:0> require 'rubygems'
> > => true
> > irb(main):002:0> require 'sqlite3'
> > LoadError: 127: The specified procedure could not be found. * -
> > Init_sqlite3
> > ./sqlite3.dll
> > * * * * from ./sqlite3.dll
> > * * * * from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> > 31:in `require'
> > * * * * from (irb):2
> > irb(main):003:0>
> > ===

>
> > Is this saying there is something wrong with the downloaded sqlite3
> > DLL itself?

>
> No, the problem is Ruby itself.
>
> C:\Users\Luis>irb
> irb(main):001:0> require 'rbconfig'
> => true
> irb(main):002:0> RbConfig::CONFIG['DLEXT']
> => "so"
> irb(main):003:0> RbConfig::CONFIG['DLEXT2']
> => "dll"
>
> DLEXT is used to identify Ruby C extensions.
>
> Since you're CD'ing from Ruby\bin, it's finding 'sqlite3.dll' and
> think it is an extension. See this:
>
> C:\Users\Luis>cd Tools\bin
>
> C:\Users\Luis\Tools\bin>dir sqlite*.*
> *Volume in drive C is Windows7
> *Volume Serial Number is 50BD-564E
>
> *Directory of C:\Users\Luis\Tools\bin
>
> 18/05/2009 *01:40 p.m. * * * * * 505.873 sqlite3.dll
> 21/05/2009 *10:03 p.m. * * * * * 520.574 sqlite3.exe
> * * * * * * * *2 File(s) * * *1.026.447 bytes
> * * * * * * * *0 Dir(s) *44.951.277.568 bytes free
>
> C:\Users\Luis\Tools\bin>irb
> irb(main):001:0> require 'sqlite3'
> LoadError: 127: The specified procedure could not be found. * -
> Init_sqlite3
> ./sqlite3.dll
> * * * * from ./sqlite3.dll
> * * * * from (irb):1
>
> Now, please try doing the require OUTSIDE Ruby\bin folder.
>
> Also, since you installed sqlite3 as a gem, please require rubygems
> first:
>
> require 'rubygems'
> require 'sqlite3'
>
> HTH
> --
> Luis Lavena


This last post is correct. I had to do this:
(1) move the script to another directory other than C:\Ruby\bin
(2) added require 'rubygems' about the require 'sqlite3'
(3) Make a couple of minor script corrections -- the following now
works fine:
===
require 'rubygems'
require 'sqlite3'
db = SQLite3:atabase.new( "test.db" )
db.execute( "drop table if exists the_table " )
sql = <<SQL
create table the_table (
a varchar2(30),
b varchar2(30)
);

insert into the_table values ( 'one', 'two' );
insert into the_table values ( 'three', 'four' );
insert into the_table values ( 'five', 'six' );
SQL
db.execute_batch( sql )
print db.execute( "select * from the_table" )
===
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't install sqlite3-ruby gem in Windows Nova Pon Ruby 5 06-06-2009 06:41 PM
sqlite3-ruby gem install problem Tom Cloyd Ruby 3 08-04-2008 03:02 PM
"require 'sqlite3'" gives "no such file to load -- sqlite3 (LoadError)" Jeffrey 'jf' Lim Ruby 5 04-09-2007 10:58 AM
RubyGems 0.9.1 calling a gem with gem '<gem>' Austin 7873 Ruby 5 01-27-2007 10:05 PM
Problem: Gem-installed sqlite3 once again basi Ruby 6 10-11-2005 06:19 PM



Advertisments