質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

1回答

1470閲覧

rails new 時のsqlite3エラー

mobunaga

総合スコア4

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2019/08/23 07:06

rails new ~を実行した際、以下のエラーが出てしまいます

Installing

1Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 2 3current directory: 4c:/railsruby/test1_app/vendor/bundle/gems/sqlite3-1.4.1/ext/sqlite3 5C:/Ruby25-x64/bin/ruby.exe -r ./siteconf20190823-5556-1kbpw6e.rb extconf.rb 6*** extconf.rb failed *** 7Could not create Makefile due to some reason, probably lack of necessary 8libraries and/or headers. Check the mkmf.log file for more details. You may 9need configuration options. 10 11Provided configuration options: 12 --with-opt-dir 13 --without-opt-dir 14 --with-opt-include 15 --without-opt-include=${opt-dir}/include 16 --with-opt-lib 17 --without-opt-lib=${opt-dir}/lib 18 --with-make-prog 19 --without-make-prog 20 --srcdir=. 21 --curdir 22 --ruby=C:/Ruby25-x64/bin/$(RUBY_BASE_NAME) 23 --with-sqlcipher 24 --without-sqlcipher 25 --with-sqlite3-config 26 --without-sqlite3-config 27 --with-pkg-config 28 --without-pkg-config 29C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to 30generate an executable file. (RuntimeError) 31You have to install development tools first. 32 from C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:541:in `try_link0' 33 from C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:559:in `try_link' 34 from C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:661:in `try_ldflags' 35 from C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:1821:in `pkg_config' 36 from extconf.rb:35:in `<main>' 37 38To see why this extension failed to compile, please check the mkmf.log which can 39be found here: 40 41c:/railsruby/test1_app/vendor/bundle/extensions/x64-mingw32/2.5.0/sqlite3-1.4.1/mkmf.log 42 43extconf failed, exit code 1 44 45Gem files will remain installed in 46c:/railsruby/test1_app/vendor/bundle/gems/sqlite3-1.4.1 for inspection. 47Results logged to 48c:/railsruby/test1_app/vendor/bundle/extensions/x64-mingw32/2.5.0/sqlite3-1.4.1/gem_make.out 49 50An error occurred while installing sqlite3 (1.4.1), and Bundler cannot continue. 51Make sure that `gem install sqlite3 -v '1.4.1' --source 'https://rubygems.org/'` 52succeeds before bundling. 53 54In Gemfile: 55 sqlite3 56 run bundle binstubs bundler 57Could not find gem 'sqlite3 (~> 1.4) x64-mingw32' in any of the gem sources 58listed in your Gemfile. 59 rails webpacker:install 60Could not find gem 'sqlite3 (~> 1.4) x64-mingw32' in any of the gem sources listed in your Gemfile. 61Run `bundle install` to install missing gems.

エラーに従って、
sqlite3のインストールを実行すると、

c:\railsruby>gem

1Temporarily enhancing PATH for MSYS/MINGW... 2Installing required msys2 packages: mingw-w64-x86_64-sqlite3 3警告: mingw-w64-x86_64-sqlite3-3.29.0-2 は最新です -- スキップ 4Building native extensions. This could take a while... 5ERROR: Error installing sqlite3: 6 ERROR: Failed to build gem native extension. 7 8 current directory: C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.4.1/ext/sqlite3 9C:/Ruby25-x64/bin/ruby.exe -r ./siteconf20190823-7920-1veyfxm.rb extconf.rb 10*** extconf.rb failed *** 11Could not create Makefile due to some reason, probably lack of necessary 12libraries and/or headers. Check the mkmf.log file for more details. You may 13need configuration options. 14 15Provided configuration options: 16 --with-opt-dir 17 --without-opt-dir 18 --with-opt-include 19 --without-opt-include=${opt-dir}/include 20 --with-opt-lib 21 --without-opt-lib=${opt-dir}/lib 22 --with-make-prog 23 --without-make-prog 24 --srcdir=. 25 --curdir 26 --ruby=C:/Ruby25-x64/bin/$(RUBY_BASE_NAME) 27 --with-sqlcipher 28 --without-sqlcipher 29 --with-sqlite3-config 30 --without-sqlite3-config 31 --with-pkg-config 32 --without-pkg-config 33C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError) 34You have to install development tools first. 35 from C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:541:in `try_link0' 36 from C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:559:in `try_link' 37 from C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:661:in `try_ldflags' 38 from C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:1821:in `pkg_config' 39 from extconf.rb:35:in `<main>' 40 41To see why this extension failed to compile, please check the mkmf.log which can be found here: 42 43 C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/sqlite3-1.4.1/mkmf.log 44 45extconf failed, exit code 1 46 47Gem files will remain installed in C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.4.1 for inspection. 48Results logged to C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/sqlite3-1.4.1/gem_make.out

と表示されます。
bundle installもエラーにより完了できません。
どうすればいいでしょうか?
初学者のため質問が拙くて恐縮ですがよろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

こんばんは。解決されていますでしょうか?
できればOSのバージョンやRubyのバージョンも添えていただけるといいと思います!

ログを見たところ、Windows環境のようですね。
過去のTeratailのトピックに参考になりそうなのがあるので、こちらをご覧になってはいかがでしょうか。
(過去に回答してくださった方々のおかげです...)

rubyのGem以外に、一応SQLiteのソースファイル、DLLも必要になりますので、そちらも合わせて確認してみてくださいね。

20190824追記:

タイミング的にRails6なんですね!

RubyのインストールはRubyInstallerでしょうか。
純粋にRubyだけを使うのではなく、Cのバイナリをつかうようなケースでは、他にMSYS2というものが必要になります。こちらも追加されていますでしょうか?(導入済みでしたらすみません)

いくつか方法を試されていて、ちょっと環境がわかりにくくなってしまったかもしれませんが、まずは1つずつアンインストールしてみてから、再セットアップを進めてみてはいかがでしょう。

私自身がWindowsを現在使っていないので、例が出せず申し訳ないのですが、Progate様でご提供して下さっている手順をご確認くださいね。

https://prog-8.com/docs/ruby-env-win

投稿2019/08/23 11:22

編集2019/08/24 07:48
suama

総合スコア1997

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

mobunaga

2019/08/23 17:17

遅くなって申し訳ありません。 回答ありがとうございます。 環境ですが、 win7 ruby2.5.5 rails6.0.0 です。 提示頂いたURLを参考にしまして、 gemfileのsqlite3を1.3.6に指定、 sqlite3.hをCドライブ直下に作成したsqlite3というフォルダに配置、 sqlite3.dllをruby2.5.5のbin内に配置、 gem install sqlite3 --platform=ruby -- --with-sqlite3-include=C:/sqlite3 --with-sqlite3-lib=C:/Ruby25-x64/bin を実行したのですが、 ERROR: While executing gem ... (Gem::UnsatisfiableDependencyError) Unable to resolve dependency: No match for 'psych (= 3.1.0)' on this platform. Found: x64-mingw32 と返されてしまいます。
mobunaga

2019/08/23 17:48

又、いま新たにrails newを実行してみたところ、やはりsqlite3のビルドエラーが発生し、 c:\railsruby>gem install sqlite3 --platform=ruby -- --with-sqlite3-include=C:/sqlite3 --with-sqlite3-lib=C:/Ruby25-x64/bin を再度実行すると、 Temporarily enhancing PATH for MSYS/MINGW... Installing required msys2 packages: mingw-w64-x86_64-sqlite3 警告: mingw-w64-x86_64-sqlite3-3.29.0-2 は最新です -- スキップ Building native extensions with: '--with-sqlite3-include=C:/sqlite3 --with-sqlite3-lib=C:/Ruby25-x64/bin' This could take a while... ERROR: Error installing sqlite3: ERROR: Failed to build gem native extension. current directory: C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.4.1/ext/sqlite3 C:/Ruby25-x64/bin/ruby.exe -r ./siteconf20190824-11060-1xrk14n.rb extconf.rb --with-sqlite3-include=C:/sqlite3 --with-sqlite3-lib=C:/Ruby25-x64/bin *** 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-x64/bin/$(RUBY_BASE_NAME) --with-sqlcipher --without-sqlcipher --with-sqlite3-config --without-sqlite3-config --with-pkg-config --without-pkg-config C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:541:in `try_link0' from C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:559:in `try_link' from C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:661:in `try_ldflags' from C:/Ruby25-x64/lib/ruby/2.5.0/mkmf.rb:1821:in `pkg_config' from extconf.rb:35:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/sqlite3-1.4.1/mkmf.log extconf failed, exit code 1 Gem files will remain installed in C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.4.1 for inspection. Results logged to C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/sqlite3-1.4.1/gem_make.out と帰ってきました。 これはdevelopment toolsをインストールしろということなのでしょうか? また、この場合必要なdevelopment toolsとは何か重ねてお教えいただきたいです。 どうかよろしくお願いします。
mobunaga

2019/08/23 17:59

重ねて追記です。 mkmf.logは "pkg-config --exists sqlite3" | pkg-config --libs sqlite3 => "-LC:/Ruby25-x64/msys64/mingw64/lib -lsqlite3\n" "x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/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 -O3 -fno-fast-math conftest.c -L. -LC:/Ruby25-x64/lib -L. -pipe -s -lx64-msvcrt-ruby250 -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi " This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Cannot create temporary file in C:\Users?????\AppData\Local\Temp\: Invalid argument 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 */ となっています。
suama

2019/08/24 07:48

こんにちは! 私自身がWindowsを現在使っていないので、例が出せず申し訳ないのですが、思い当たるところを回答に追記してみました。 解決につながればよいのですが。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問