次の環境でテストをしています。
OS : Windows10
Ruby : 2.6.5
Ruby on rails : 6.0.2.1
WindowsにRubyとRailsをインストールした後、sqlite3をインストールしようとすると、次のエラーが発生しました。
C:>gem install sqlite
Fetching sqlite-1.0.2.gem
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR: Error installing sqlite:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite-1.0.2/ext/sqlite
C:/Ruby26-x64/bin/ruby.exe -I C:/Ruby26-x64/lib/ruby/2.6.0 -r ./siteconf20200124-15124-lbvrdk.rb extconf.rb
checking for malloc()... yes
checking for free()... yes
creating Makefile
current directory: C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite-1.0.2/ext/sqlite
make "DESTDIR=" clean
current directory: C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite-1.0.2/ext/sqlite
make "DESTDIR="
generating sqlite-x64-mingw32.def
compiling main.c
In file included from main.c:3:
ruby_sqlite3.h:4:10: fatal error: sqlite3.h: No such file or directory
4 | #include "sqlite3.h"
| ^~~~~~~~~~~
compilation terminated.
make: *** [Makefile:244: main.o] エラー 1
make failed, exit code 2
Gem files will remain installed in C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite-1.0.2 for inspection.
Results logged to C:/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/sqlite-1.0.2/gem_make.out
HPを検索したところ、この場合、次の方法をするといいと書いてあったので、それを試してみました。
1)HP「https://www.sqlite.org/download.html」の次のファイルをダウンロードする。
a)「sqlite-tools-win32-x86-3280000.zip」
b)「sqlite-dll-win64-x64-3280000.zip」
2)2つのファイルを解凍し、次のパスにファイルを保存する。
a)「C:\sqlite3」に「sqlite3.h」(a)を保存
b)「C:\Ruby26-x64\bin」に「sqlite3.dll」(a)を保存
3)次のコマンドを実行する。
gem install sqlite3 --platform=ruby -- --with-sqlite3-include=C:/sqlite3 --with-sqlite3-lib=C:/Ruby26-x64/bin
このコマンドでも次のエラーとなりました。
C:>gem install sqlite3 --platform=ruby -- --with-sqlite3-include=C:/sqlite3 --with-sqlite3-lib=C:/Ruby26-x64/bin
Temporarily enhancing PATH for MSYS/MINGW...
Installing required msys2 packages: mingw-w64-x86_64-sqlite3
エラー: mingw32: "Alexey Pavlov (Alexpux) alexpux@gmail.com" の署名は信頼されていません
エラー: mingw64: "Alexey Pavlov (Alexpux) alexpux@gmail.com" の署名は信頼されていません
エラー: msys: "Alexey Pavlov (Alexpux) alexpux@gmail.com" の署名は信頼されていません
エラー: データベース 'mingw32' は無効です (無効または破損したデータベース (PGP 鍵))
エラー: データベース 'mingw64' は無効です (無効または破損したデータベース (PGP 鍵))
エラー: データベース 'msys' は無効です (無効または破損したデータベース (PGP 鍵))
pacman failed with the following output:
Building native extensions with: '--with-sqlite3-include=C:/sqlite3 --with-sqlite3-lib=C:/Ruby26-x64/bin'
This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.2/ext/sqlite3
C:/Ruby26-x64/bin/ruby.exe -I C:/Ruby26-x64/lib/ruby/2.6.0 -r ./siteconf20200124-22272-gy7aq.rb extconf.rb --with-sqlite3-include=C:/sqlite3 --with-sqlite3-lib=C:/Ruby26-x64/bin
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:/Ruby26-x64/bin/$(RUBY_BASE_NAME)
--with-sqlcipher
--without-sqlcipher
--with-sqlite3-config
--without-sqlite3-config
--with-pkg-config
--without-pkg-config
--with-sqlcipher
--without-sqlcipher
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib=${sqlite3-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/sqlite3-1.4.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.2 for inspection.
Results logged to C:/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/sqlite3-1.4.2/gem_make.out
エラーとならないようにするにはどうすればいいのでしょうか?