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

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

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

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

Ruby

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

SQLite

SQLiteはリレーショナルデータベース管理システムの1つで、サーバーではなくライブラリとして使用されている。

Ruby on Rails

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

Q&A

解決済

3回答

1127閲覧

Windows10でのRuby,Railsの環境構築のエラー

maco-curry

総合スコア7

Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

Ruby

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

SQLite

SQLiteはリレーショナルデータベース管理システムの1つで、サーバーではなくライブラリとして使用されている。

Ruby on Rails

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

0グッド

2クリップ

投稿2019/09/10 04:28

前提・実現したいこと

Windows10にてRuby、Railsの環境構築をしたいのですが、
rails newコマンドの段階でエラーが出ました。

ネット情報を元に解決策を探しましたが、自力では難しいため、
みなさんのお力を借りて、環境構築を実現したいです。


<エラーが出るまでの手順>
① MSYS2のインストール
② RubyInstallersでのRubyのインストール
※=> Ruby+Devkit 2.5.5-1(x64)
③ bundleのインストール
※コマンドプロンプトにてgem install bundler
④ SQlite3をダウンロードしてsqlite3とsqlite3.dllをRuby25-x64のbinに展開
⑤ Railsのインストール
※コマンドプロンプトにてgem install rails
⑥ 任意のディレクトリにてrails newコマンドの実行→エラー発生


<参考にした情報>
QiitaのRails環境構築
ProgateのRails環境構築

SQlite3は画像の下2つをダウンロードしました。
ダウンロード画面

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

エラーメッセージ C:\Users\secret\sample>rails new TestApp 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.

試したこと

エラーメッセージからGemfileもしくはSQlite3に問題があるということはわかるのですが、
恥ずかしながら、ネット情報にて解決策を探してもわからず、自力では難しいと考えて今に至ります。

以下、rails newコマンド全文になります。 C:\Users\secret\sample>rails new TestApp create create README.md create Rakefile create .ruby-version create config.ru create .gitignore create Gemfile run git init from "." create package.json create app create app/assets/config/manifest.js create app/assets/stylesheets/application.css create app/channels/application_cable/channel.rb create app/channels/application_cable/connection.rb create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/javascript/channels/consumer.js create app/javascript/channels/index.js create app/javascript/packs/application.js create app/jobs/application_job.rb create app/mailers/application_mailer.rb create app/models/application_record.rb create app/views/layouts/application.html.erb create app/views/layouts/mailer.html.erb create app/views/layouts/mailer.text.erb create app/assets/images/.keep create app/controllers/concerns/.keep create app/models/concerns/.keep create bin create bin/rails create bin/rake create bin/setup create bin/yarn create config create config/routes.rb create config/application.rb create config/environment.rb create config/cable.yml create config/puma.rb create config/storage.yml create config/environments create config/environments/development.rb create config/environments/production.rb create config/environments/test.rb create config/initializers create config/initializers/application_controller_renderer.rb create config/initializers/assets.rb create config/initializers/backtrace_silencers.rb create config/initializers/content_security_policy.rb create config/initializers/cookies_serializer.rb create config/initializers/cors.rb create config/initializers/filter_parameter_logging.rb create config/initializers/inflections.rb create config/initializers/mime_types.rb create config/initializers/new_framework_defaults_6_0.rb create config/initializers/wrap_parameters.rb create config/locales create config/locales/en.yml create config/master.key append .gitignore create config/boot.rb create config/database.yml create db create db/seeds.rb create lib create lib/tasks create lib/tasks/.keep create lib/assets create lib/assets/.keep create log create log/.keep create public create public/404.html create public/422.html create public/500.html create public/apple-touch-icon-precomposed.png create public/apple-touch-icon.png create public/favicon.ico create public/robots.txt create tmp create tmp/.keep create tmp/cache create tmp/cache/assets create vendor create vendor/.keep create test/fixtures create test/fixtures/.keep create test/fixtures/files create test/fixtures/files/.keep create test/controllers create test/controllers/.keep create test/mailers create test/mailers/.keep create test/models create test/models/.keep create test/helpers create test/helpers/.keep create test/integration create test/integration/.keep create test/channels/application_cable/connection_test.rb create test/test_helper.rb create test/system create test/system/.keep create test/application_system_test_case.rb create storage create storage/.keep create tmp/storage create tmp/storage/.keep remove config/initializers/cors.rb remove config/initializers/new_framework_defaults_6_0.rb run bundle install Fetching gem metadata from https://rubygems.org/............. Fetching gem metadata from https://rubygems.org/. Resolving dependencies.... Using rake 12.3.3 Using concurrent-ruby 1.1.5 Using i18n 1.6.0 Using minitest 5.11.3 Using thread_safe 0.3.6 Using tzinfo 1.2.5 Using zeitwerk 2.1.10 Using activesupport 6.0.0 Using builder 3.2.3 Using erubi 1.8.0 Using mini_portile2 2.4.0 Using nokogiri 1.10.4 (x64-mingw32) Using rails-dom-testing 2.0.3 Using crass 1.0.4 Using loofah 2.2.3 Using rails-html-sanitizer 1.2.0 Using actionview 6.0.0 Using rack 2.0.7 Using rack-test 1.1.0 Using actionpack 6.0.0 Using nio4r 2.5.1 Using websocket-extensions 0.1.4 Using websocket-driver 0.7.1 Using actioncable 6.0.0 Using globalid 0.4.2 Using activejob 6.0.0 Using activemodel 6.0.0 Using activerecord 6.0.0 Using mimemagic 0.3.3 Using marcel 0.3.3 Using activestorage 6.0.0 Using mini_mime 1.0.2 Using mail 2.7.1 Using actionmailbox 6.0.0 Using actionmailer 6.0.0 Using actiontext 6.0.0 Using public_suffix 4.0.1 Using addressable 2.7.0 Using bindex 0.8.1 Using msgpack 1.3.1 (x64-mingw32) Using bootsnap 1.4.5 Using bundler 2.0.2 Using byebug 11.0.1 Using regexp_parser 1.6.0 Using xpath 3.2.0 Using capybara 3.29.0 Using childprocess 2.0.0 Using ffi 1.11.1 (x64-mingw32) Using jbuilder 2.9.1 Using method_source 0.9.2 Using puma 3.12.1 Using rack-proxy 0.6.5 Using thor 0.20.3 Using railties 6.0.0 Using sprockets 3.7.2 Using sprockets-rails 3.2.1 Using rails 6.0.0 Using rb-fsevent 0.10.3 Using rb-inotify 0.10.0 Using rubyzip 1.2.4 Using sass-listen 4.0.0 Using sass 3.7.4 Using tilt 2.0.9 Using sass-rails 5.1.0 Using selenium-webdriver 3.142.4 Fetching sqlite3 1.4.1 Installing sqlite3 1.4.1 with native extensions Gem::Ext::BuildError: 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 ./siteconf20190910-1496-78uk70.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:/Ruby25-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:/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 An error occurred while installing sqlite3 (1.4.1), and Bundler cannot continue. Make sure that `gem install sqlite3 -v '1.4.1' --source 'https://rubygems.org/'` succeeds before bundling. 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. C:\Users\secret\sample>

補足情報(バージョン)

・ruby 2.5.5p157 (2019-03-15 revision 67260) [x64-mingw32]
・Rails 6.0.0
・Bundler version 2.0.2
・gem -v → 2.7.6.2
・sqlite3 --version →
3.29.0 2019-07-10 17:32:03 fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88bfa6

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

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

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

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

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

guest

回答3

0

コメントを参考に、SQlite3のバージョンを下げることでサーバーを立てることができました!

具体的な手順としては、
① MSYS2のインストール
② RubyInstallersでのRubyのインストール
※=> Ruby+Devkit 2.4.7-1(x64)
③ bundleのインストール
※コマンドプロンプトにてgem install bundler
④ SQlite3をダウンロードしてsqlite3とsqlite3.dllをRuby25-x64のbinに展開
⑤ Railsのインストール
※コマンドプロンプトにてgem install -v rails 5.2.2 
⑥ 任意のディレクトリにてrails new TestApp --skip-bundle
⑦ TestAppのGemfileでSQlite3の書き換え
※gem 'sqlite3' から gem 'sqlite3', '~> 1.3.13' へ
⑧コマンドプロンプトにてTestAppまで移動し、bundle installコマンドの実行
⑨rails serverコマンドの実行

各ステップの詳細は質問文中の2つのRails環境構築の記事を見れば、
難なく進められると思います。

今回のポイントは、
Rubyを2.4系で、Railsを5.2.2のバージョンでインストールしたことと
Gemfileを編集してSQlite3のバージョンを下げたことが挙げられます。

最後に、この質問が私と同じようなプログラミング初心者の役に立てば幸いです。

投稿2019/09/10 13:03

maco-curry

総合スコア7

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

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

0

RailsInstallerはどうですか?

投稿2019/09/10 10:50

退会済みユーザー

退会済みユーザー

総合スコア0

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

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

maco-curry

2019/09/10 12:33

試してみる前に解決してしまいました! ご回答ありがとうございました!
guest

0

ベストアンサー

sqliteのバージョンを下げて回避できる記事を見かけます。
試してみてください。

Gemfile

1gem 'sqlite3', '~> 1.3.13'

投稿2019/09/10 05:16

編集2019/09/10 05:33
mt_

総合スコア14

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

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

maco-curry

2019/09/10 06:38

ご回答ありがとうございます。 質問文中のQiitaの環境構築の記事にsqliteのバージョンを下げる手順があったので試しました。 具体的には、rails newコマンドを--skip-bundleをつけて実行し、 Gemfileでsqliteのバージョンを変更した後、 作成したディレクトリ中でbundle installコマンドを実行しました。 そして、いよいよrails sコマンドを実行したのですが、 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError) というエラーメッセージが表示されてしまいました。 記事の最後にも、Rubyの2.5系ではこの段階でsqliteに問題が出ると書いていたため、 Rubyのバージョンを2.4系にして、改めて実行してみようかと、今は考えています。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問