2

I set my ruby default using Chruby ruby version control but when I try and rails new it is using my system version. How do I fix this?

~/workspace ❯❯❯ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin14]
~/workspace ❯❯❯ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin14]
~/workspace ❯❯❯ rails new gitsee   
    Rails 5 requires Ruby 2.2.2 or newer.

    You're running
      ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

    Please upgrade to Ruby 2.2.2 or newer to continue.
matt
  • 78,533
  • 8
  • 163
  • 197
phillipjones1
  • 327
  • 2
  • 11

1 Answers1

6

It looks like you’ve got Rails installed in the system Ruby but not in the chruby managed 2.2.3. Since the system Ruby gem executables are in /usr/bin/ they will be found when you are running a different version and don’t have the gem installed in that version.

To check, run which rails (make sure you have used chruby to select the recent Ruby first). You will probably see /usr/bin/rails as the result.

The fix is simply to install Rails in the new Ruby (again, make sure you’ve selected 2.3.1 with chruby first):

$ gem install rails
matt
  • 78,533
  • 8
  • 163
  • 197