前提・実現したいこと
ruby on railsの環境を構築するためにbundle installを実行したいのですが、エラーが出てしまいます。
https://blog.codecamp.jp/rails-for-win
このサイトに従って作業を進めています。
pcはwindows10の64bit、rubyは2.6.1、sqlite3は3.27.2、railsは5.2.2.1です。
コマンドプロンプトを用いて実践しています。
発生している問題・エラーメッセージ
上記サイトのgem install railsのところまでは指示通りに進められ、その後Rubyのフォルダにrailsフォルダがなかったので自分で作り、cd C:¥Ruby¥railsを実行し、rails new firstappを実行しました。firstappは問題なく作られていたように思います。そしてcd firstappを実行し、bundle installとしたとき、事件は起こりました。
c:\Ruby\rails\firstapp>bundle install
Fetching gem metadata from https://rubygems.org/.............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies......
Using rake 12.3.2
Using concurrent-ruby 1.1.5
(中略)
Using sass-rails 5.0.7
Using selenium-webdriver 3.141.0
Fetching sqlite3 1.4.0
Installing sqlite3 1.4.0 with native extensions
ここで一旦インストールが止まり、次の瞬間、
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
C:/Ruby/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.0/ext/sqlite3
C:/Ruby/bin/ruby.exe -I C:/Ruby/lib/ruby/2.6.0 -r
./siteconf20190326-8780-him67w.rb extconf.rb
checking for sqlite3.h... yes
checking for pthread_create() in -lpthread... yes
checking for -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:/Ruby/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
--with-pthreadlib
--without-pthreadlib
--with-dllib
--without-dllib
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
C:/Ruby/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/sqlite3-1.4.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
C:/Ruby/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.0 for inspection.
Results logged to
C:/Ruby/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/sqlite3-1.4.0/gem_make.out
An error occurred while installing sqlite3 (1.4.0), and Bundler cannot continue.
Make sure that gem install sqlite3 -v '1.4.0' --source 'https://rubygems.org/'
succeeds before bundling.
In Gemfile:
sqlite3
このようなエラーが出てしまいました、、、
rails serverを実行しても、
c:\Ruby\rails\firstapp>rails server
Could not find gem 'sqlite3 x64-mingw32' in any of the gem sources listed in your Gemfile.
Run bundle install
to install missing gems.
上記のようなエラーが出てしまいます。
試したこと
エラー文を見ている感じだと、sqlite3がどうやら引っかかっている感じがしたので、まずはc:/Ruby/binにsqlite3.exeとsqlite3.hとsqlite3.dllを置きました。次にコマンドプロンプトに
c:\Ruby\rails\firstapp>gem install sqlite3
と打って実行してみると上記のエラー文と似たようなエラー文が出てきました。
そのエラー文をもとにいろいろ検索してみると、
https://teratail.com/questions/173639
ここに全く同じエラー文で悩んでいる人を見つけました。この回答に沿って
gem install specific_install
gem specific_install -l https://github.com/larskanis/sqlite3-ruby -b add-gemspec
これを実行してみたところ、(gitのpathは通してありました。)どうやらsqlite3はインストールできたようです。が、再度rails serverを実行すると今度は、
Could not find gem 'uglifier (>= 1.3.0) x64-mingw32' in any of the gem sources listed in your Gemfile.
Run bundle install
to install missing gems.
と、sqlite3ではなくuglifierとかいうのに阻まれまして、これはbundle installを正常に実行させない限り一生終わらないと悟りました。
なお、この状態でbundle installを実行してもやはりInstalling sqlite3のところで止まり、全く同じエラー文が表示されます。
ちなみになのですが、rails serverのコマンドはc:\Ruby\rails\firstapp>のプロンプトで実行してエラーが出ており、このプロンプトでrail --versionを実行しても、全く同じエラーが出ます。しかし、c:\Ruby\rails>のプロンプトでrail --versionを実行すると、
c:\Ruby\rails>rails --version
Rails 5.2.2.1
このようにちゃんとversionを返してくれます。なぜなのでしょうか、、、
冗長な質問文で申し訳ありませんでしたが、回答よろしくお願いします。また私は、railsは今日初めて触らせていただきましたので知識等はございません。どうぞお手柔らかにお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/27 09:32