Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine ruby version from within Rails

Is there a way to determine what version of Ruby is running from within Rails (either on the web or through script/console)? I have Ruby 1.8.6 installed but I've also installed Ruby Enterprise Edition 1.8.7-20090928 and want to ensure that it's using the right installation.

like image 489
Daniel Vandersluis Avatar asked Oct 19 '09 16:10

Daniel Vandersluis


People also ask

How do I check ruby on Rails version?

Step 1: Check Ruby VersionOpen the command prompt and type ruby -v. If Ruby responds, and if it shows a version number at or above 2.2. 2, then type gem --version. If you don't get an error, skip Install Ruby step.

How do I know if Rbenv is installed?

You can see if it is using rbenv by typing which ruby and it should print something out with . rbenv/ whatever. If not you need to set rbenv as your current ruby.


1 Answers

Use this global constant:

RUBY_VERSION 

Other relevant global constants include:

RUBY_PATCHLEVEL RUBY_PLATFORM RUBY_RELEASE_DATE 

Usage example via irb session:

irb(main):001:0> RUBY_VERSION => "1.8.7" 
like image 129
trondozer Avatar answered Oct 20 '22 11:10

trondozer