2

I am trying to upgrade from ruby 2.3.0 to 2.4.1. To do this, I did rvm use 2.4.1@my-project --create (I am already using 2.4.1 for another project). I changed the gemfile from ruby "2.3.0" to ruby "2.4.1", and I ran bundle install. My gemfile.lock correctly changed.

However, when trying to run rails s in console, I have the error:

Your Ruby version is 2.3.1, but your Gemfile specified 2.4.1

This is not logical because when I am running which ruby I get the following answer : /.rvm/rubies/ruby-2.4.1/bin/ruby. ruby -v answers ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]. Furthermore I have never used 2.3.1 for any of my projects; when running rvm list in console, I do not see that version of ruby.

Is it possible that there is a conflict with rails? I am using rails 4.2.7.1

I tried all the answered given in the following stackoverflow issues:

So I am kind of running out of ideas. Thank you for your help!

M. S.
  • 33
  • 1
  • 6
  • does `rvm use 2.4.1; bundle; rails s` not work? – Josh Brody Jul 12 '18 at 17:12
  • 1
    What happens when you run `which rails`? What happens when you run `bundle exec rails s`? – Tom Lord Jul 12 '18 at 17:23
  • If you do `rvm use system`, does it show as version 2.3.1? I'm guessing somehow your system ruby is overriding rvm's. I would've thought the answer in first link you posted (https://stackoverflow.com/a/21082929/3477163) would have worked. Another option is to try bumping up to 2.4.2 and seeing if that helps. That won't fix the issue but it may help isolate it. – supremebeing7 Jul 13 '18 at 04:48
  • `rvm use 2.4.1; bundle; rails s` results in the same error. `which rails` results in `/usr/bin/rails`. `bundle exec rails s` seems to work, I have a new error message about about gem compatibility! `rvm use system` results in `Now using system ruby.` – M. S. Jul 13 '18 at 07:53
  • 1
    Despite `bundle exec rails s` seems to work, `bundle exec rails c` still triggers the same error... – M. S. Jul 13 '18 at 08:26
  • Are your .ruby-version and .ruby-gemset showing the correct values in the root of your project. Sounds obvious but worth checking. Also try the command "rvm list gemsets" to show the ruby version and gemset that you're using. I assumed you are not using a .rvmrc config file because you used the create command. One other thing I've found in the past that I have to "cd" out of the folder and back into the folder for it to pick up the RVM settings. – Mark Davies Jul 13 '18 at 08:34
  • @M.S. If `bundle exec rails s` works, then I have no idea why `bundle exec rails c` would fail. *Are you sure* about that error? And what is the "new error message about about gem compatibility"? – Tom Lord Jul 13 '18 at 09:03
  • @TomLord mi mistake, indeed `bundle exec rails s` and `bundle exec rails c` trigger the same compatibility error! – M. S. Jul 13 '18 at 16:18
  • @MarkDavies, I do not have such files... "cd-ing" out and back showed me that when doing only `rvm use 2.4.1` it works, but when I do rvm use `2.4.1@my-project` I get the error about the difference between gemfile and ruby version... – M. S. Jul 13 '18 at 16:34
  • I don't understand the problem, because you're giving vague and contradictory answers. If "doing `rvm use 2.4.1` works", which is the very first thing that was suggested, then I consider the situation resolved. If it doesn't work, then I don't know what the error is. You should never face a situation where running `bundle install` runs successfully, then `bundle exec ` complains about an incompatible bundle. – Tom Lord Jul 14 '18 at 10:51
  • When you run a rvm create command ( EG rvm --ruby-version use 2.4.1@my-project --create ) it should create a .ruby-gemset containing the text 'my-project' and a .ruby-version file with the text 'ruby-2.4.1'. Both files should be created in the folder where you issued the command so make sure that is the root of your project. So whenever you change directory into a project with these files RVM knows to set your ruby version and gemset appropriately. It could be that your install of RVM has become corrupt if it is not doing this. – Mark Davies Jul 16 '18 at 07:56
  • If RVM is doing it's job and setting the ruby version and gemset then there is no need to specifically hardcode the ruby version in the gemfile. – Mark Davies Jul 16 '18 at 07:58

1 Answers1

0

I faced same issue, stopping spring and clearing tmp, which includes bootsnap cache worked for me

spring stop
rake tmp:clear
Tachyons
  • 2,131
  • 1
  • 21
  • 35