Q&A
#つまずいている事
rails初心者です。
現在、rails tutorialの2章を進めています。
データベースの作成の際に以下コマンドを実行し、
②の後に以下エラーが発生し進めなくなっています。
#実行したコマンド
①rails generate scaffold User name:string email:string
②rails db:migrate
#発生したエラー
XXXXXX:~/environment/toy_app (master) $ rails db:migrate
Could not find gem 'pg (= 0.20.0)' in any of the gem sources listed in your Gemfile.
Run bundle install to install missing gems.
#エラー後の対処
'pg (= 0.20.0)'がインストールされていないことがわかったので
gemfileを再度bundle installを実行。
※以下のgemfileはこの手順の前に一度「bundle install --without production」で
インストールをしたはずだった。
#gemfileの内容
source 'https://rubygems.org'
gem 'rails', '5.1.6'
gem 'puma', '3.9.1'
gem 'sass-rails', '5.0.6'
gem 'uglifier', '3.2.0'
gem 'coffee-rails', '4.2.2'
gem 'jquery-rails', '4.3.1'
gem 'turbolinks', '5.0.1'
gem 'jbuilder', '2.7.0'
group :development, :test do
gem 'sqlite3', '1.3.13'
gem 'byebug', '9.0.6', platform: :mri
end
group :development do
gem 'web-console', '3.5.1'
gem 'listen', '3.1.5'
gem 'spring', '2.0.2'
gem 'spring-watcher-listen', '2.0.1'
end
group :production do
gem 'pg', '0.20.0'
end
Windows環境ではtzinfo-dataというgemを含める必要があります
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
#再度budle instasllした際のエラー内容
XXXXX:~/environment/toy_app (master) $ bundle install
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java
.
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Bundler could not find compatible versions for gem "activesupport":
In snapshot (Gemfile.lock):
activesupport (= 5.1.6.1)
In Gemfile:
rails (= 5.1.6) was resolved to 5.1.6, which depends on
activesupport (= 5.1.6)
coffee-rails (= 4.2.2) was resolved to 4.2.2, which depends on railties (>= 4.0.0) was resolved to 5.1.6.1, which depends on activesupport (= 5.1.6.1)
Running bundle update
will rebuild your snapshot from scratch, using
only
the gems in your Gemfile, which may resolve the conflict.
#お願い
一人では解決が難しいため
どなたかアドバイスをよろしくお願いします。
以上です。
回答1件
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。