2

I'm sure this is a very common question, but I can't make it work even after following several tutorials about it. I'm using Ubuntu 16.04 lts and I just installed Ruby on Rails with Rbenv, but then, after running rails server I get the Your Ruby version is 2.3.1, but your Gemfile specified 2.1.4 message. How can I make it work?

Ryuuks
  • 380
  • 2
  • 18
  • 1
    Either install ruby 2.1.4 and use it. Or update your gemfile to use ruby 2.3.1 (something might not work here, if not all of your code is compatible with 2.3.1) – Sergio Tulentsev Sep 13 '16 at 16:26
  • Are you using RVM or something like that to support different versions of Ruby on your machine? – MarsAtomic Sep 13 '16 at 16:43
  • @MarsAtomic - He is using rbenv. – B Seven Sep 13 '16 at 17:01
  • I tried to install 2.1.4 but it didn't work for some reason, probably cause I'm doing it wrong. I can't update the gemfile, has to be 2.1.4 – Ryuuks Sep 13 '16 at 17:03

2 Answers2

2

As Sergio pointed you, you need to update your Ruby or your Gemfile.

In my experience, there are not a lot of major changes between Ruby 2.1 and 2.3, so I suggest updating your Gemfile.

If you don't want to do that, then here is how to install Ruby 2.1.4:

rbenv install 2.1.4

Also, be sure to set the version:

rbenv local 2.1.4

ruby -v

Should return 2.1.4

rbenv reference

B Seven
  • 44,484
  • 66
  • 240
  • 385
  • `# rbenv install 2.1.4 rbenv: /home/ricardo/.rbenv/versions/2.1.4 already exists continue with installation? (y/N) y Downloading ruby-2.1.4.tar.bz2... -> https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.4.tar.bz2 Installing ruby-2.1.4... WARNING: ruby-2.1.4 is nearing its end of life. It only receives critical security updates, no bug fixes. Installed ruby-2.1.4 to /home/ricardo/.rbenv/versions/2.1.4` – Ryuuks Sep 13 '16 at 17:41
  • It worked, but now I have loop issue: when I set it to 2.1.4 it says The `rails' command exists in these Ruby versions: 2.3.1, but if I set it to 2.3.1 it says Your Ruby version is 2.3.1, but your Gemfile specified 2.1.4 ... And I know it worked on this laptop with the same gemfile before – Ryuuks Sep 14 '16 at 10:49
  • `gem install bundler; bundle` – B Seven Sep 14 '16 at 18:04
0
rvm --default use 2.1.4

rvm use 2.1.4@"folder name" --create
jay.pepper
  • 17
  • 7