Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sprockets requires Ruby version >= 2.5.0 on rails 5

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?

like image 913
Lucian Tarna Avatar asked Oct 09 '19 10:10

Lucian Tarna


3 Answers

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

like image 118
Yury Matusevich Avatar answered Nov 01 '22 13:11

Yury Matusevich


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
like image 9
wrsx Avatar answered Nov 01 '22 15:11

wrsx


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?

like image 1
mahatmanich Avatar answered Nov 01 '22 13:11

mahatmanich