rails-sqlserver / tiny_tds

TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library.
Other
607 stars 189 forks source link

Windows 7. LoadError: cannot load such file -- tiny_tds/tiny_tds #416

Closed JohnAtFenestra closed 5 years ago

JohnAtFenestra commented 5 years ago

Before submitting an issue please check these first!

If none of these help. Please fill out the following:

Environment

Operating System

>systeminfo | findstr /C:OS          
OS Name:                   Microsoft Windows 7 Ultimate                                               
OS Version:                6.1.7601 Service Pack 1 Build 7601                                         
OS Manufacturer:           Microsoft Corporation                                                      
OS Configuration:          Standalone Workstation                                                     
OS Build Type:             Multiprocessor Free                                                        
BIOS Version:              innotek GmbH VirtualBox, 12/1/2006                                         

TinyTDS Version and Information

>tsql-ttds -C
[TinyTds][v2.1.2][tsql]: C:/Ruby24/lib/ruby/gems/2.4.0/gems/tiny_tds-2.1.2-x86-mingw32/ports/i686-w64-mingw32/freetds/1.00.27/bin/tsql.EXE
Compile-time settings (established with the "configure" script)
                            Version: freetds v1.00.27
             freetds.conf directory: C:/Sites
     MS db-lib source compatibility: no
        Sybase binary compatibility: no
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 7.3
                              iODBC: no
                           unixodbc: no
              SSPI "trusted" logins: yes
                           Kerberos: no
                            OpenSSL: yes
                             GnuTLS: no
                               MARS: no

Description

I am encountering this issue on Windows 7 using straight Ruby.

>ruby --version
ruby 2.4.4p296 (2018-03-28 revision 63013) [i386-mingw32]
>gem list tiny_tds

*** LOCAL GEMS ***

tiny_tds (2.1.2 x86-mingw32)

I added a tiny piece of logging to tiny_tds.rb to report the attempted load version and to report the exception message in the rescue.

# Temporary add bin directories for DLL search, so that freetds DLLs can be found.
  add_dll_paths.call( TinyTds::Gem.ports_bin_paths ) do
    begin
      puts "tiny_tds/#{ver}/tiny_tds"
      require "tiny_tds/#{ver}/tiny_tds"
    rescue LoadError => boom
      puts boom.message
      require 'tiny_tds/tiny_tds'
    end
  end

Here are the results of IRB. Note that I explicitly require devkit before requiring tiny_tds:

>irb                                                                                                                      
irb(main):001:0> require 'devkit'                                                                                                              
=> true                                                                                                                                        
irb(main):002:0> require 'tiny_tds'                                                                                                            
tiny_tds/2.4/tiny_tds                                                                                                                          
126: The specified module could not be found.   - C:/Ruby24/lib/ruby/gems/2.4.0/gems/tiny_tds-2.1.2-x86-mingw32/lib/tiny_tds/2.4/tiny_tds.so   
tiny_tds/2.4/tiny_tds                                                                                                                          
126: The specified module could not be found.   - C:/Ruby24/lib/ruby/gems/2.4.0/gems/tiny_tds-2.1.2-x86-mingw32/lib/tiny_tds/2.4/tiny_tds.so   
tiny_tds/2.4/tiny_tds                                                                                                                          
126: The specified module could not be found.   - C:/Ruby24/lib/ruby/gems/2.4.0/gems/tiny_tds-2.1.2-x86-mingw32/lib/tiny_tds/2.4/tiny_tds.so   
tiny_tds/2.4/tiny_tds                                                                                                                          
126: The specified module could not be found.   - C:/Ruby24/lib/ruby/gems/2.4.0/gems/tiny_tds-2.1.2-x86-mingw32/lib/tiny_tds/2.4/tiny_tds.so   
LoadError: cannot load such file -- tiny_tds/tiny_tds                                                                                          
        from C:/Ruby24/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'                                                      
        from C:/Ruby24/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'                                                      
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/tiny_tds-2.1.2-x86-mingw32/lib/tiny_tds.rb:48:in `rescue in block in <top (required)>'         
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/tiny_tds-2.1.2-x86-mingw32/lib/tiny_tds.rb:43:in `block in <top (required)>'                   
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/tiny_tds-2.1.2-x86-mingw32/lib/tiny_tds.rb:37:in `block in <top (required)>'                   
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/tiny_tds-2.1.2-x86-mingw32/lib/tiny_tds.rb:34:in `block (2 levels) in <top (required)>'        
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/tiny_tds-2.1.2-x86-mingw32/lib/tiny_tds.rb:24:in `rescue in block in <top (required)>'         
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/tiny_tds-2.1.2-x86-mingw32/lib/tiny_tds.rb:17:in `block in <top (required)>'                   
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/tiny_tds-2.1.2-x86-mingw32/lib/tiny_tds.rb:33:in `block in <top (required)>'                   
        from C:/Ruby24/lib/ruby/gems/2.4.0/gems/tiny_tds-2.1.2-x86-mingw32/lib/tiny_tds.rb:42:in `<top (required)>'                            
        from C:/Ruby24/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `require'                                                     
        from C:/Ruby24/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'                                           
        from C:/Ruby24/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:39:in `require'                                                      
        from (irb):2                                                                                                                           
        from C:/Ruby24/bin/irb.cmd:19:in `<main>'                                                                                              
irb(main):003:0>

I have confirmed that tiny_tds.so exists at the specified location:

>dir C:\Ruby24\lib\ruby\gems\2.4.0\gems\tiny_tds-2.1.2-x86-mingw32\lib\tiny_tds\2.4
 Volume in drive C has no label.
 Volume Serial Number is 5C90-F2CA

 Directory of C:\Ruby24\lib\ruby\gems\2.4.0\gems\tiny_tds-2.1.2-x86-mingw32\lib\tiny_tds\2.4

09/24/2018  10:11 AM    <DIR>          .
09/24/2018  10:11 AM    <DIR>          ..
09/24/2018  10:11 AM           320,622 tiny_tds.so
               1 File(s)        320,622 bytes

Here is an extraction of my path. To eliminate noise, I reduced the included list to only those items containing /ruby/i in the path:

[                                                                                                                                
    "C:\\Ruby24\\bin",                                                                                                           
    "C:\\Ruby24\\lib\\ruby\\gems\\2.4.0\\gems\\tiny_tds-2.1.2-x86-mingw32\\ports\\i686-w64-mingw32\\freetds\\1.00.27\\bin",      
    "C:\\Ruby24\\lib\\ruby\\gems\\2.4.0\\gems\\tiny_tds-2.1.2-x86-mingw32\\ports\\i686-w64-mingw32\\openssl\\1.1.0e\\bin",       
    "c:\\Ruby24\\msys32\\mingw32\\bin"                                                                                           
]

I'm out of ideas of what to look at next.

JohnAtFenestra commented 5 years ago

Documenting for the future:

I happened across the fact that the current versions of Ruby for Windows require the use of --platform when building native extensions. Ergo, the installation instruction on the main page is incorrect. Use the following:

 gem install --platform ruby tiny_tds

When using Ruby for Windows > version 2.4.

metaskills commented 5 years ago

Oh interesting! Do you have a link to docs on that arg in ruby gems? I've not seen that before.

JohnAtFenestra commented 5 years ago

https://rubyinstaller.org/2017/05/25/rubyinstaller-2.4.1-1-released.html

And for the clear record, using the argument makes tiny_tds work fine:

>irb
irb(main):001:0> require 'tiny_tds'
=> true