sprockets requires Ruby version >= 2.5.0 on rails 5
Asked Answered
R

3

8

I have rvm installed on my PC with the default ruby gemset being 2.4.1

rvm list
   ruby-2.4.0 [ x86_64 ]
=* ruby-2.4.1 [ x86_64 ]
   ruby-2.6.3 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

I want to install rails 5 however sprockets fails to install requiring 2.5 ruby. However rails 5 should work with any ruby above 2.2.2:

gem install rails -v 5.1.4
Fetching: activesupport-5.1.4.gem (100%)
Successfully installed activesupport-5.1.4
Fetching: actionview-5.1.4.gem (100%)
Successfully installed actionview-5.1.4
Fetching: actionpack-5.1.4.gem (100%)
Successfully installed actionpack-5.1.4
ERROR:  Error installing rails:
    sprockets requires Ruby version >= 2.5.0.

I don't care about the rails 5 version. The newer the better, but all versions do give me the errors

Any idea why this might happen?

Radical answered 9/10, 2019 at 10:51 Comment(0)
B
14

The latest (4.0.0) version of sprockets really requires ruby >= 2.5.0. Check it here

Is gem 'sprockets' in your Gemfile set to a specific version?

To manually change version of sprockets add the line bellow to your Gemfile

gem 'sprockets', '~> 3.7.2'

If you do not have a Gemfile yet try direct installation.

gem install sprockets -v 3.7.2

Balmacaan answered 9/10, 2019 at 11:33 Comment(2)
I do not have a gemfile, the folder is just empty , wanted to do a rails new but for that needed to install rails.Radical
I do not know why, but this doesn't work for me, but direct sprockets installation from other answer works like a charmHonewort
D
9

For those that are experiencing this without having it explicitly specified in the gemfile, another workaround is to install the previous version manually:

gem install sprockets -v 3.7.2
Diligent answered 10/10, 2019 at 4:12 Comment(0)
T
1

Rails 5 may only require Ruby => 2.2.2 but if you don't version gems in your Gemfile it will always pull down the latest version of the gems. A later gem version then might need a higher version of Ruby.

This however has nothing to do with rails!

Also you might have a Problem with Ruby 2.4.1 using it with Rails 5.1.4

Which Ruby on Rails is compatible with which Ruby version?

Trothplight answered 9/10, 2019 at 11:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.