LoginSignup
7
4

More than 5 years have passed since last update.

2019年4月現在Railsインストール時に起きたエラーと解決策

Posted at

環境

Windows7 64bit

エラー内容

rails newコマンドを実行すると
次のrails serverコマンドでエラーが出る

コマンドプロンプト
rails server

Could not find gem 'sqlite3 x86-mingw32' in any of the gem sources listed in you
r Gemfile or available on this machine.
(Gemfileにリストされている、またはこのマシンで利用可能なgemソースのいずれかにgem 'sqlite3 x86-mingw32'が見つかりませんでした。)
Run `bundle install` to install missing gems.
(足りないgemをインストールするために `bundle install`を実行してください。)

bundle installを試してもエラーが出る
コマンドプロンプト
bundle install

Fetching gem metadata from https://rubygems.org/..............
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 12.3.2
Using concurrent-ruby 1.1.5
Using minitest 5.11.3
Using thread_safe 0.3.6
Using builder 3.2.3
Using erubis 2.7.0
Using mini_portile2 2.4.0
Using crass 1.0.4
Using rack 2.0.7
Using nio4r 2.3.1
Using websocket-extensions 0.1.3
Using mini_mime 1.0.1
Using arel 7.1.4
Using bindex 0.7.0
Using bundler 1.13.6
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using method_source 0.9.2
Using thor 0.20.3
Using ffi 1.10.0
Using multi_json 1.13.1
Using puma 3.12.1
Using rb-fsevent 0.10.3
Using tilt 2.0.9
Installing sqlite3 1.4.0 with native extensions
Using turbolinks-source 5.2.0
Installing i18n 1.6.0
Using tzinfo 1.2.5
Installing nokogiri 1.10.2
Using rack-test 0.6.3
Using sprockets 3.7.2
Using websocket-driver 0.6.5
Using mail 2.7.1
Using coffee-script 2.4.1
Using uglifier 4.1.20
Using rb-inotify 0.10.0
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

C:/RailsInstaller/Ruby2.2.0/bin/ruby.exe -r
./siteconf20190413-8660-1gagbbb.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.
(何らかの理由でMakefileを作成できませんでした。おそらく必要なライブラリやヘッダーが不足しています。 詳細については、mkmf.logファイルを確 認してください。 設定オプションが必要になるかもしれません。)

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:/RailsInstaller/Ruby2.2.0/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
        --without-sqlite3-include=${sqlite3-dir}/include
        --with-sqlite3-lib
        --without-sqlite3-lib=${sqlite3-dir}/lib

extconf failed, exit code 1

Gem files will remain installed in
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/sqlite3-1.4.0 for
inspection.
Results logged to
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/extensions/x86-mingw32/2.2.0/sql
ite3-1.4.0/gem_make.out

An error occurred while installing sqlite3 (1.4.0), and Bundler cannot continue.
(sqlite3(1.4.0)のインストール中にエラーが発生し、Bundlerは続行できません。)

Make sure that `gem install sqlite3 -v '1.4.0'` succeeds before bundling.
(バンドルする前に `gem install sqlite3 -v '1.4.0'が成功することを確認してください。)

sqlite3 -v '1.4.0'を試してもエラーが出る
コマンドプロンプト
sqlite3 -v '1.4.0'

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3:
        ERROR: Failed to build gem native extension.
Gemネイティブエクステンションの構築に失敗しました。

    C:/RailsInstaller/Ruby2.2.0/bin/ruby.exe -r ./siteconf20190413-8772-tajpma.r
b extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Install SQLite3 from http://www.sqlite.org/ first.
sqlite3.hが見つかりません。
*** 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:/RailsInstaller/Ruby2.2.0/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
        --without-sqlite3-include=${sqlite3-dir}/include
        --with-sqlite3-lib
        --without-sqlite3-lib=${sqlite3-dir}/lib

extconf failed, exit code 1

Gem files will remain installed in C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2
.0/gems/sqlite3-1.4.0 for inspection.
Results logged to C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/extensions/x86
-mingw32/2.2.0/sqlite3-1.4.0/gem_make.out

sqlite3.hをパスの通った所においてもエラーが出る
コマンドプロント
gem install sqlite3 --platform=ruby -- --with-sqlite3-include=C:/sqlite3/ --with-sqlite3-lib=C:/sqlite3/dll

Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-sqlite3-include=C:/sqlite3/ --with-sqli
te3-lib=C:/sqlite3/dll'
This could take a while...
ERROR:  Error installing sqlite3:
        ERROR: Failed to build gem native extension.

    C:/RailsInstaller/Ruby2.2.0/bin/ruby.exe -r ./siteconf20190413-9596-gytlp9.r
b extconf.rb --with-sqlite3-include=C:/sqlite3/ --with-sqlite3-lib=C:/sqlite3/dl
l
checking for sqlite3.h... yes
checking for pthread_create() in -lpthread... no
checking for main() in -ldl... no
checking for dlopen()... no
missing function dlopen
*** 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:/RailsInstaller/Ruby2.2.0/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
        --with-pthreadlib
        --without-pthreadlib
        --with-dllib
        --without-dllib

extconf failed, exit code 1

Gem files will remain installed in C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2
.0/gems/sqlite3-1.4.0 for inspection.
Results logged to C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/extensions/x86
-mingw32/2.2.0/sqlite3-1.4.0/gem_make.out

解決策

正解はこの記事が知っていた
「Windows10でRuby on Railsの環境構築」
https://qiita.com/shita_fontaine/items/aa3f762d7afa20c5d42a
どうやら2019年2月から4月15日現在ではrails newではエラーが起きるらしい。

原因はrails newコマンド。このコマンドはアプリケーションを作るコマンドであるが、実行されるbundle installコマンドにて、sqlite3を使用するgemのinstallが行われる。
そのgemのversionが1.4.0であり、1.4.0は2019年2月4日に追加されたばかりであったためか、gem installコマンドを利用すると下記のようなエラーを吐く。

解決策は、rails newコマンドに--skip-bundleオプションをつけて実行し、Gemfileのsqliteのバージョンを編集し、bundle installを実行することらしい。

全てをインストールし直し試してみると成功。
メモ代わりに残す。

7
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
4