stef
stef

Reputation: 27749

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 https://get.rvm.io | 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)

Upvotes: 2

Views: 670

Answers (4)

Marlon Monroy
Marlon Monroy

Reputation: 144

If you have multiple version installed than you can use rvm to make ruby 2.3.1 your default: rvm --default use 2.1.1

Upvotes: -1

Todd A. Jacobs
Todd A. Jacobs

Reputation: 84343

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.

Upvotes: 1

Mark Setchell
Mark Setchell

Reputation: 207455

You have installed the homebrew version 2.3.1 of Ruby, but you are not using it because you haven't set your PATH correctly.

Try using the one homebrew installed for you by adding /usr/local/bin to the start of you PATH, or by running:

/usr/local/bin/ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

I guess if you use the Apple-supplied Ruby in /usr/bin you will get:

/usr/bin/ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]

Upvotes: 1

Gabriel C
Gabriel C

Reputation: 263

You should uninstall ruby from brew and just use rvm.

Upvotes: 0

Related Questions