Help us understand the problem. What is going on with this article?

【Rails5.2.4】rails newしたらsass-railsとsprocketsのバージョンが合わなくてエラー発生

はじめに

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

バージョン指定を外してあげれば無事通るようになりました。

おわりに

最後まで読んで頂きありがとうございました:bow_tone1:

どなたかのエラー解決時間の短縮につながればと思います。:relaxed:

参考にさせて頂いたサイト(いつもありがとうございます)

【Rails】Vue.js入門してみた。(rails new ~ hello?) - おぴよの気まぐれ日記

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした