stef stef - 5 months ago 13
Ruby Question

OSX not using latest Ruby version

When I try to run a ruby command in terminal I get an error:

Ruby >= 2.1.9 required to run app (You have 2.0.0)

When I try

brew upgrade ruby

I get

Error: ruby 2.3.1 already installed

Previously I tried installing ruby with rvm

curl -sSL | bash -s stable --ruby

Maybe I have two different versions of ruby running?

How can I get my system to use the latest version of ruby?

EDIT: Definitely two versions installed

/usr/local/bin/ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin14]
ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

My $PATH seems correct?

-bash: /usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin: No such file or directory

EDIT2 specifying the full path to the correct version of ruby:

/usr/local/bin/ruby app.rb
/usr/local/bin/ruby: No such file or directory -- app (LoadError)


In the simplest cases, you can just specify the fully-qualified PATH to your Homebrew-installed Ruby. For example:

/usr/local/bin/ruby /path/to/foo.rb

However, if you need to require gems or libraries, you need to step up your game with a Ruby version manager such as chruby, rvm, or rbenv. You should never replace the system ruby, and managing all the environments variables, gems, and so forth that Ruby needs without a version manager is outside the scope of a reasonable Stack Overflow question.