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

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

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

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

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

Q&A

1回答

986閲覧

Ruby on Railsの環境構築 サーバーが立ち上がりません。

takuyavox

総合スコア4

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

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

1グッド

1クリップ

投稿2020/03/14 16:33

前提・実現したいこと

Ruby on Railsの環境構築をprogateさんの手順通りに進めているのですが、localhostのサーバーにアクセスができません。
コマンドプロンプトを使っています。

発生している問題・エラーメッセージ

C:\Users\TAKUYA\sample_app>rails s Could not find gem 'sqlite3 (~> 1.4) x64-mingw32' in any of the gem sources listed in your Gemfile. Run `bundle install` to install missing gems.

該当のソースコード

C:\Users\TAKUYA>ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x64-mingw32]

C:\Users\TAKUYA>rails -v
Rails 6.0.2.1

試したこと

progateさんより

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

もし、sqlite3のインストールに失敗してエラーが出るようであれば、以下のコマンドを実行してください。
cd sample_app
ridk exec pacman -S mingw-w64-x86_64-sqlite3
その後、以下のコマンドを実行してください。
bundle install
正常にbundle installが成功したら、Railsアプリケーションの作成は完了です。

ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
C:\Users\TAKUYA\sample_app>ridk exec pacman -S mingw-w64-x86_64-sqlite3
エラー: mingw32: キー "AD351C50AE085775EB59333B5F92EFC1A47D45A1" は不明です
エラー: キー "AD351C50AE085775EB59333B5F92EFC1A47D45A1" をリモートで検索できませんでした
エラー: mingw64: キー "AD351C50AE085775EB59333B5F92EFC1A47D45A1" は不明です
エラー: キー "AD351C50AE085775EB59333B5F92EFC1A47D45A1" をリモートで検索できませんでした
エラー: msys: キー "AD351C50AE085775EB59333B5F92EFC1A47D45A1" は不明です
エラー: キー "AD351C50AE085775EB59333B5F92EFC1A47D45A1" をリモートで検索できませんでした
エラー: データベース 'mingw32' は無効です (無効または破損したデータベース (PGP 鍵))
エラー: データベース 'mingw64' は無効です (無効または破損したデータベース (PGP 鍵))
エラー: データベース 'msys' は無効です (無効または破損したデータベース (PGP 鍵))

ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
C:\Users\TAKUYA\sample_app>bundle install
Fetching gem metadata from https://rubygems.org/.............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies.......
Using rake 13.0.1
Using concurrent-ruby 1.1.6
Using i18n 1.8.2
Using minitest 5.14.0
Using thread_safe 0.3.6
Using tzinfo 1.2.6
Using zeitwerk 2.3.0
Using activesupport 6.0.2.1
Using builder 3.2.4
Using erubi 1.9.0
Using mini_portile2 2.4.0
Using nokogiri 1.10.9 (x64-mingw32)
Using rails-dom-testing 2.0.3
Using crass 1.0.6
Using loofah 2.4.0
Using rails-html-sanitizer 1.3.0
Using actionview 6.0.2.1
Using rack 2.2.2
Using rack-test 1.1.0
Using actionpack 6.0.2.1
Using nio4r 2.5.2
Using websocket-extensions 0.1.4
Using websocket-driver 0.7.1
Using actioncable 6.0.2.1
Using globalid 0.4.2
Using activejob 6.0.2.1
Using activemodel 6.0.2.1
Using activerecord 6.0.2.1
Using mimemagic 0.3.4
Using marcel 0.3.3
Using activestorage 6.0.2.1
Using mini_mime 1.0.2
Using mail 2.7.1
Using actionmailbox 6.0.2.1
Using actionmailer 6.0.2.1
Using actiontext 6.0.2.1
Using public_suffix 4.0.3
Using addressable 2.7.0
Using bindex 0.8.1
Using msgpack 1.3.3 (x64-mingw32)
Using bootsnap 1.4.6
Using bundler 2.1.4
Using byebug 11.1.1
Using regexp_parser 1.7.0
Using xpath 3.2.0
Using capybara 3.31.0
Using childprocess 3.0.0
Using ffi 1.12.2 (x64-mingw32)
Using jbuilder 2.10.0
Using method_source 0.9.2
Using puma 4.3.3
Using rack-proxy 0.6.5
Using thor 1.0.1
Using railties 6.0.2.1
Using sprockets 4.0.0
Using sprockets-rails 3.2.1
Using rails 6.0.2.1
Using rubyzip 2.3.0
Using sassc 2.2.1 (x64-mingw32)
Using tilt 2.0.10
Using sassc-rails 2.1.2
Using sass-rails 6.0.0
Using selenium-webdriver 3.142.7
Fetching sqlite3 1.4.2
Installing sqlite3 1.4.2 with native extensions
Gem::Ext::BuildError: 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
./siteconf20200315-20452-99mas6.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:/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
--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:/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

An error occurred while installing sqlite3 (1.4.2), and Bundler cannot continue.
Make sure that gem install sqlite3 -v '1.4.2' --source 'https://rubygems.org/'
succeeds before bundling.

In Gemfile:
sqlite3

補足情報(FW/ツールのバージョンなど)

手順はあっていると思うのですが、上手くサーバーがたちあがりません。
いろいろ他の質問やネットで調べたところ、
bandle,gem,git,sqlite3,webpacker,辺りに何か問題があるかなとは思うのですが・・・
バージョンがあってないとか?
どなたか詳しい方助けていただけると幸いです。
どうかよろしくお願いいたします。

s.k👍を押しています

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

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

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

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

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

guest

回答1

0

バージョンがあってないとか?

Windows10でRails動かしてますが、あなたと同じバージョンなので問題は無いと思います。
セットアップの手順の問題でしょう。

Ruby 2.6.5p114 (2019-10-01 revision 67812) [x64-mingw32]
Rails 6.0.2.1
bundle 1.17.2
gem 3.0.3

あと、railsアプリ構築に必要なツールとしてはこんなところです。
前もって入れておけばいいでしょう。
git 2.23.0
sqlite3 3.31.1
yarn 1.22.4

投稿2020/03/14 17:31

technocore

総合スコア7200

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

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

takuyavox

2020/03/15 01:00

ご回答ありがとうございます! C:\Users\TAKUYA>bundle -v Bundler version 2.1.4 C:\Users\TAKUYA>gem -v 3.0.3 C:\Users\TAKUYA>sqlite3.exe --version 3.31.1 2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837bb4d6 C:\Users\TAKUYA>git -v 'git' は、内部コマンドまたは外部コマンド、 操作可能なプログラムまたはバッチ ファイルとして認識されていませ C:\Users\TAKUYA>yarn -v 'yarn' は、内部コマンドまたは外部コマンド、 操作可能なプログラムまたはバッチ ファイルとして認識されていません。 となるので、gitとyarnが問題のようでしょうか? gitはGit-2.25.1-64-bitをインストールしてGitBashはwindowsにあります。 gitBashでバージョン確認すると表示されるのですが、 コマンドプロンプトだと表示されません。 多分インストール方法?場所?を間違えてるのかと思うのですが、 調べても古いバージョンの参考資料しかなく、いまいちわかりません。
takuyavox

2020/03/15 01:23

C:\Users\TAKUYA>yarn -v 1.22.4 あとはgitが問題だと思います
takuyavox

2020/03/15 01:44

PS C:\Users\TAKUYA> git --version git version 2.25.1.windows.1 VS CODE で使えるようにインストールしました。 コマンドプロントで使えるようにはなっていないようです。
takuyavox

2020/03/15 01:55

結局同じエラーが出てサーバーたてれませんでした。 rais new ruby_app みたいな感じで1から作りましたがだめでした。 問題がありそうな箇所を教えていただけるとありがたいです。 よろしくお願いします。
technocore

2020/03/15 02:25

railsアプリの環境作りは、通常、アプリフォルダ内で完結させます。 ・アプリ用のフォルダを作る ・そのフォルダ内にcdする ・bundle initでGemfileを新規作成する ・Gemfileを開いてrailsの行をコメントアウトする  (この時、railsのバージョンも指定できる) ・bundleのインストール  (エラーが出るなら解決する) ・rails newの実行  (エラーが出るなら解決する) ・エラーなく終了したらrails s みたいな手順になります。
takuyavox

2020/03/15 03:27

ありがとうございます!やってみました PS C:\Users\TAKUYA> bundle init Writing new Gemfile to C:/Users/TAKUYA/Gemfile Gemfile内↓ # frozen_string_literal: true source "https://rubygems.org" git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } gem "rails"  ※コメントを外しました! PS C:\Users\TAKUYA> bundle install Bundle complete! 1 Gemfile dependency, 43 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. 多分ここまでは大丈夫だと思います。 PS C:\Users\TAKUYA> rails new rails_app -G Gem::Ext::BuildError: ERROR: Failed to build gem native extension. In Gemfile: sqlite3 run bundle binstubs bundler Could not find gem 'sqlite3 (~> 1.4) x64-mingw32' in any of the gem sources listed in your Gemfile. rails webpacker:install Could not find gem 'sqlite3 (~> 1.4) x64-mingw32' in any of the gem sources listed in your Gemfile. Run `bundle install` to install missing gems. ここのエラーは sqlite3 のバージョンを下げろという意味でしょうか???
technocore

2020/03/15 03:36

Gemfileを修正したのちの手順ですが bundleのインストールはこんな手順 > bundle config set path 'vendor/bundle' > bundle install それができたらrails構築は > bundle exec rails new . とします。配下に構築するので最後は「.」をつける おそらく依存関係のエラーがでるので Gemfileの修正とbundle updateを繰り返します。
takuyavox

2020/03/15 04:12

PS C:\Users\TAKUYA\rails_app> bundle config set path 'vendor/bundle' PS C:\Users\TAKUYA\rails_app> bundle install ・・・・省略 Fetching sqlite3 1.4.2 Installing sqlite3 1.4.2 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: C:/Users/TAKUYA/Rails_App/vendor/bundle/ruby/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 ./siteconf20200315-8268-a8b0yo.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:/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 --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:/Users/TAKUYA/Rails_App/vendor/bundle/ruby/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:/Users/TAKUYA/Rails_App/vendor/bundle/ruby/2.6.0/gems/sqlite3-1.4.2 for Results logged to C:/Users/TAKUYA/Rails_App/vendor/bundle/ruby/2.6.0/extensions/x64-mingw32/2.6.0/sqlite3-1.4.2/gem_make.out An error occurred while installing sqlite3 (1.4.2), and Bundler cannot continue. Make sure that `gem install sqlite3 -v '1.4.2' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: sqlite3 PS C:\Users\TAKUYA\rails_app> bundle exec rails new . Could not find gem 'sqlite3 (~> 1.4) x64-mingw32' in any of the gem sources listed in your Gemfile. Run `bundle install` to install missing gems. PS C:\Users\TAKUYA\rails_app> >bundle install 時にエラーが起きている?なぜでしょうか・・・
technocore

2020/03/15 04:27

私の環境ではそんなエラーは出ないですね。 とりあえずエラーメッセージにあるように、 gem install sqlite3 -v '1.4.2' を実行してみてはいかがでしょう? それから、念のためこれも解決しておいた方が安心です。 >git version 2.25.1.windows.1 >VS CODE で使えるようにインストールしました。 >コマンドプロントで使えるようにはなっていないようです。
takuyavox

2020/03/15 04:38

PS C:\Users\TAKUYA\rails_app> gem install sqlite3 -v '1.4.2' Temporarily enhancing PATH for MSYS/MINGW... Installing required msys2 packages: mingw-w64-x86_64-sqlite3 エラー: mingw32: キー "AD351C50AE085775EB59333B5F92EFC1A47D45A1" は不明です エラー: キー "AD351C50AE085775EB59333B5F92EFC1A47D45A1" をリモートで検索できませんでした エラー: mingw64: キー "AD351C50AE085775EB59333B5F92EFC1A47D45A1" は不明です エラー: キー "AD351C50AE085775EB59333B5F92EFC1A47D45A1" をリモートで検索できませんでした エラー: msys: キー "AD351C50AE085775EB59333B5F92EFC1A47D45A1" は不明です エラー: キー "AD351C50AE085775EB59333B5F92EFC1A47D45A1" をリモートで検索できませんでした エラー: データベース 'mingw32' は無効です (無効または破損したデータベース (PGP 鍵)) エラー: データベース 'mingw64' は無効です (無効または破損したデータベース (PGP 鍵)) エラー: データベース 'msys' は無効です (無効または破損したデータベース (PGP 鍵)) pacman failed with the following output: Building native extensions. 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 ./siteconf20200315-17924-s0oq13.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:/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 --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:/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 すでにエラーがでています・・・ コマンドプロンプトで使エルヨウニインストールしたつもりなんですが、なぜか使えません・・・
takuyavox

2020/03/15 08:43

ありがとうございます。 sqlite3 は無事インストールできました。 その後再度 bundle install で以前と同じくエラーが出ます。 もう3日かけてできないので諦めます。 本当にありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問