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

Discussion in 'Ruby' started by SunSw0rd, Jul 1, 2009.

  1. SunSw0rd

    SunSw0rd Guest

    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::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?
     
    SunSw0rd, Jul 1, 2009
    #1
    1. Advertisements

  2. SunSw0rd

    SunSw0rd Guest

    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?
     
    SunSw0rd, Jul 1, 2009
    #2
    1. Advertisements

  3. > 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/.
     
    Michael Linfield, Jul 1, 2009
    #3
  4. SunSw0rd

    Luis Lavena Guest

    On Jul 1, 6:27 pm, SunSw0rd <> 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
     
    Luis Lavena, Jul 2, 2009
    #4
  5. SunSw0rd

    SunSw0rd Guest

    On Jul 1, 10:52 pm, Luis Lavena <> wrote:
    > On Jul 1, 6:27 pm, SunSw0rd <> 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::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" )
    ===
     
    SunSw0rd, Jul 2, 2009
    #5
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joshua Wehner

    Gem install sqlite3-ruby

    Joshua Wehner, Jul 12, 2006, in forum: Ruby
    Replies:
    0
    Views:
    202
    Joshua Wehner
    Jul 12, 2006
  2. Austin 7873
    Replies:
    5
    Views:
    316
    Eric Hodel
    Jan 27, 2007
  3. Jeffrey 'jf' Lim
    Replies:
    5
    Views:
    657
    Jeffrey 'jf' Lim
    Apr 9, 2007
  4. Tom Cloyd

    sqlite3-ruby gem install problem

    Tom Cloyd, Aug 4, 2008, in forum: Ruby
    Replies:
    3
    Views:
    200
    Tom Cloyd
    Aug 4, 2008
  5. Nova Pon
    Replies:
    5
    Views:
    1,086
    Roger Pack
    Jun 6, 2009
Loading...

Share This Page