はじめに
Rails+Vue.jsの環境構築をしていたときに発生した単純なエラーについて解決法を残します。
環境
OS: macOS Catalina 10.15.1
zsh: 5.7.1
Ruby: 2.6.5
Rails: 5.2.4.1
エラー内容
$ rails new
...略
Resolving dependencies....
Bundler could not find compatible versions for gem "sprockets":
In snapshot (Gemfile.lock):
sprockets (= 4.0.0)
In Gemfile:
sass-rails (~> 5.0) was resolved to 5.1.0, which depends on
sprockets (>= 2.8, < 4.0)
rails (~> 5.2.4, >= 5.2.4.1) was resolved to 5.2.4.1, which depends on
sprockets-rails (>= 2.0.0) was resolved to 3.2.1, which depends on
sprockets (>= 3.0.0)
Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
rails webpacker:install
Could not find gem 'mysql2 (>= 0.4.4, < 0.6.0)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
...略
sprockets
のバージョンが4.0.0
だけど、
sass-rails(~> 5.0)
はsprockets(>= 2.8, < 4.0)
に対応してるからうまくいかないよ!という内容。
解決法
Gemfile
gem 'sass-rails', '~> 5.0'
↓
Gemfile
gem 'sass-rails'
↓
$ bundle install
バージョン指定を外してあげれば無事通るようになりました。
おわりに
最後まで読んで頂きありがとうございました
どなたかのエラー解決時間の短縮につながればと思います。