sqlite3-ruby: Cannot load such file -- sqlite3/sqlite3_native (LoadError)

At this time I just updated the ruby ​​to the ruby ​​version 2.5.1p57 (revision 2018-03-29 63029) [i386-mingw32] update it with rubyinstaller-devkit-2.5.1-2-x86. exe , when I try to execute rails s shows me this error :

$ rails s
C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': cannot load such file -- 
sqlite3/sqlite3_native (LoadError)
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport- 
 5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport- 
 5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport- 
 5.2.1/lib/active_support/dependencies.rb:287:in `require'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/sqlite3-1.3.13-x86-mingw32/lib/sqlite3.rb:6:in `rescue in 
 <top (required)>'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/sqlite3-1.3.13-x86-mingw32/lib/sqlite3.rb:2:in `<top 
 (required)>'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
 1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
 1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in 
 require_with_bootsnap_lfi'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
 1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
 1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
  1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bundler-1.16.4/lib/bundler/runtime.rb:81:in `block (2 
  levels) in require'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bundler-1.16.4/lib/bundler/runtime.rb:76:in `each'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bundler-1.16.4/lib/bundler/runtime.rb:76:in `block in 
 require'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bundler-1.16.4/lib/bundler/runtime.rb:65:in `each'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bundler-1.16.4/lib/bundler/runtime.rb:65:in `require'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bundler-1.16.4/lib/bundler.rb:114:in `require'
     from C:/users/angulo/projects_ruby/projects_rails/rails_app/config/application.rb:18:in `<top 
 (required)>'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
 1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
 1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in 
 require_with_bootsnap_lfi'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
 1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
 1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
 1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport- 
 5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport- 
 5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport- 
 5.2.1/lib/active_support/dependencies.rb:287:in `require'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/railties- 
 5.2.1/lib/rails/commands/server/server_command.rb:145:in `block in perform'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/railties- 
 5.2.1/lib/rails/commands/server/server_command.rb:142:in `tap'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/railties- 
 5.2.1/lib/rails/commands/server/server_command.rb:142:in `perform'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in ` 
 invoke_command'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/command/base.rb:65:in `perform'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/command.rb:46:in `invoke'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<top 
 (required)>'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap 
-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
      from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
 1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in 
require_with_bootsnap_lfi'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/bootsnap- 
1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport- 
5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport- 
5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
     from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport- 
5.2.1/lib/active_support/dependencies.rb:287:in `require'
    from bin/rails:4:in `<main>'

Clearly does not let me require 'sqlite3'

I try to solve it with issues like : https://github.com/sparklemotion/sqlite3-ruby/issues/185 , https://github.com/sparklemotion/sqlite3-ruby/issues/185 , but none of the solutions that this poetry worked for me

My environment :

  • Windows 7 x32 bits
  • ruby ​​version `2.5.1p57 (revision 2018-03-29 63029) [i386-mingw32]
  • Rails 5.2.1

To reproduce :

  • run rails new rails_app
  • run rails s

I hope it is solved, Thanks for reading

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 6
  • Comments: 46 (2 by maintainers)

Most upvoted comments

This still fixes it for me.

gem uninstall sqlite3 --all
ridk exec pacman -S mingw-w64-x86_64-sqlite3
gem inst sqlite3 --platform ruby

@Learning191 , I am still facing the same issue. Were you able to resolve it ?

Re installing on Windows with Ruby >= 2.4, used the following with both Ruby trunk & 2.5.3:

ridk exec pacman -S mingw-w64-x86_64-sqlite3
ridk exec pacman -S mingw-w64-x86_64-dlfcn
gem install sqlite3

This was helpful in resolving it more permanently for me: https://github.com/sparklemotion/sqlite3-ruby/issues/241#issuecomment-431700715

@Learning191 , you can use : https://github.com/sparklemotion/sqlite3-ruby/issues/224#issuecomment-416800097,

I tried resolving by the above method and got the server working for ruby 2.5 and rails 5.2.1. There seems to be a sqllite3 issue.

@alaurie sorry, absolutely no success:

C:\WortsammlerBib.1.8.1>ridk exec pacman -S mingw-w64-x86_64-sqlite3
Warnung: mingw-w64-x86_64-sqlite3-3.15.0-1 ist aktuell -- Reinstalliere
Löse Abhängigkeiten auf...
Suche nach in Konflikt stehenden Paketen...

Pakete (1) mingw-w64-x86_64-sqlite3-3.15.0-1

Gesamtgröße der installierten Pakete:  4,56 MiB
Größendifferenz der Aktualisierung:  0,00 MiB

:: Installation fortsetzen? [J/n] J
(1/1) Prüfe Schlüssel im Schlüsselring                                                                                                        [#####################################################################################] 100%
(1/1) Überprüfe Paket-Integrität                                                                                                              [#####################################################################################] 100%
(1/1) Lade Paket-Dateien                                                                                                                      [#####################################################################################] 100%
(1/1) Prüfe auf Dateikonflikte                                                                                                                [#####################################################################################] 100%
(1/1) Überprüfe verfügbaren Festplattenspeicher                                                                                               [#####################################################################################] 100%
:: Verarbeite Paketänderungen...
(1/1) Installiere mingw-w64-x86_64-sqlite3                                                                                                    [#####################################################################################] 100%

C:\WortsammlerBib.1.8.1>gem inst sqlite3 --platform ruby
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR:  Error installing sqlite3:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby25/lib/ruby/gems/2.5.0/gems/sqlite3-1.3.13/ext/sqlite3
C:/Ruby25/bin/ruby.exe -r ./siteconf20190130-1612-1p58hii.rb extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Install SQLite3 from http://www.sqlite.org/ first.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby25/bin/$(RUBY_BASE_NAME)
        --with-sqlite3-config
        --without-sqlite3-config
        --with-pkg-config
        --without-pkg-config
        --with-sqlite3-dir
        --without-sqlite3-dir
        --with-sqlite3-include
        --without-sqlite3-include=${sqlite3-dir}/include
        --with-sqlite3-lib
        --without-sqlite3-lib=${sqlite3-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/Ruby25/lib/ruby/gems/2.5.0/extensions/x86-mingw32/2.5.0/sqlite3-1.3.13/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby25/lib/ruby/gems/2.5.0/gems/sqlite3-1.3.13 for inspection.
Results logged to C:/Ruby25/lib/ruby/gems/2.5.0/extensions/x86-mingw32/2.5.0/sqlite3-1.3.13/gem_make.out

this is the … mkmf.log

"pkg-config --exists sqlite3"
package configuration for sqlite3 is not found
find_header: checking for sqlite3.h... -------------------- no

"i686-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25/include/ruby-2.5.0/i386-mingw32 -IC:/Ruby25/include/ruby-2.5.0/ruby/backward -IC:/Ruby25/include/ruby-2.5.0 -I. -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -march=i686 -mtune=generic -O2 -pipe conftest.c  -L. -LC:/Ruby25/lib -L. -pipe -s     -lmsvcrt-ruby250  -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

"i686-w64-mingw32-gcc -E -IC:/Ruby25/include/ruby-2.5.0/i386-mingw32 -IC:/Ruby25/include/ruby-2.5.0/ruby/backward -IC:/Ruby25/include/ruby-2.5.0 -I. -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -march=i686 -mtune=generic -O2 -pipe  conftest.c -o conftest.i"
conftest.c:5:21: fatal error: sqlite3.h: No such file or directory
 #include <sqlite3.h>
                     ^
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: #include <sqlite3.h>
/* end */

--------------------

I did a search on my machine, and found

C:\msys64\mingw64\include\sqlite3.h

Same here, windows msys2