1

I've built a Rails 5 app and it's working great but I'd like to change the Ruby version I'm running it on. I'm using RVM 1.27.0 on Ubuntu 16.04. I copied the app folder to a different path and changed the versions on .ruby_version and my Gemfile:

Gemfile:

source 'https://rubygems.org'
ruby "2.2.2"

.ruby_version:

ruby-2.2.2

Once I updated these I moved out and back into the folder and ran a ruby -v:

ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]

I then ran a bundle install and everything installed without error.

However, when I ran rake -T I get this:

Your Ruby version is 2.3.1, but your Gemfile specified 2.2.2.

My $PATH looks good:

/home/ken/.rvm/gems/ruby-2.2.2/bin:/home/ken/.rvm/gems/ruby-2.2.2@global/bin:/home/ken/.rvm/rubies/ruby-2.2.2/bin:/home/ken/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

What am I missing? Where is Rails pulling the Ruby version from? How can I fix this?

user3063045
  • 2,019
  • 2
  • 22
  • 35

2 Answers2

1

You're using a system bundler which is why you're seeing a different version of ruby. All you need to do is install bundler under your current ruby version:

gem install bundler
bundle install

Once you do a bundle install you'll get the gem's built for the correct ruby version.

Ken J
  • 4,312
  • 12
  • 50
  • 86
0

The file name should be .ruby-version, not .ruby_version.

And you also should have file .ruby-gemset with content

gemset

check this link, Create .ruby-version and .ruby-gemset with rvm

You can also try spring stop and gem install bundler

Community
  • 1
  • 1