LoginSignup
4
1

More than 3 years have passed since last update.

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

Posted at

はじめに

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?) - おぴよの気まぐれ日記

4
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1