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

**URL:** <https://www.ruby-forum.com/t/windows-xp-problem-with-ruby-gem-sqlite3-ruby-and-sqlite3/171405>\
**Category:** Ruby\
**Created:** [July 1, 2009, 11:11pm UTC](https://www.ruby-forum.com/t/windows-xp-problem-with-ruby-gem-sqlite3-ruby-and-sqlite3/171405 "2009-07-01T23:11:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SunSw0rd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85f322/32.png) [@SunSw0rd](https://www.ruby-forum.com/u/SunSw0rd)\
**Post date:** [July 1, 2009, 11:11pm UTC](https://www.ruby-forum.com/t/windows-xp-problem-with-ruby-gem-sqlite3-ruby-and-sqlite3/171405/1 "2009-07-01T23:11:13Z")

</div>

# 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 [SQLite Download Page](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::Database.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?

---

<div class="post-metadata">

**Author:** ![SunSw0rd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85f322/32.png) [@SunSw0rd](https://www.ruby-forum.com/u/SunSw0rd)\
**Post date:** [July 1, 2009, 11:31pm UTC](https://www.ruby-forum.com/t/windows-xp-problem-with-ruby-gem-sqlite3-ruby-and-sqlite3/171405/2 "2009-07-01T23:31:06Z")

</div>

# 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?

---

<div class="post-metadata">

**Author:** ![SunSw0rd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85f322/32.png) [@SunSw0rd](https://www.ruby-forum.com/u/SunSw0rd)\
**Post date:** [July 1, 2009, 11:46pm UTC](https://www.ruby-forum.com/t/windows-xp-problem-with-ruby-gem-sqlite3-ruby-and-sqlite3/171405/3 "2009-07-01T23:46:15Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![SunSw0rd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85f322/32.png) [@SunSw0rd](https://www.ruby-forum.com/u/SunSw0rd)\
**Post date:** [July 2, 2009, 5:55am UTC](https://www.ruby-forum.com/t/windows-xp-problem-with-ruby-gem-sqlite3-ruby-and-sqlite3/171405/4 "2009-07-02T05:55:30Z")

</div>

On Jul 1, 6:27 pm, SunSw0rd [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> 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

---

<div class="post-metadata">

**Author:** ![SunSw0rd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/85f322/32.png) [@SunSw0rd](https://www.ruby-forum.com/u/SunSw0rd)\
**Post date:** [July 2, 2009, 4:10pm UTC](https://www.ruby-forum.com/t/windows-xp-problem-with-ruby-gem-sqlite3-ruby-and-sqlite3/171405/5 "2009-07-02T16:10:38Z")

</div>

On Jul 1, 10:52 pm, Luis L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > irb(main):002:0\> require ‘sqlite3’  
> > Is this saying there is something wrong with the downloaded sqlite3  
> > =\> “dll”  
> > Volume Serial Number is 50BD-564E  
> > LoadError: 127: The specified procedure could not be found. -  
> > require ‘rubygems’  
> > require ‘sqlite3’
> 
> ## HTH
> 
> Luis L.

# 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::Database.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” )
