Determine ruby version from within Rails
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"
How to find out which rails version an existing rails application is built on?
rake gems
will print out what gems, dependencies, and versions are installed, frozen, etc.
If you are using bundler than you can use bundle show
to list all the gems that your app is using.
Rails 5: How Do I Find Out Which Gem Depends on a Specific Ruby Version?
Your case seems like not a gem dependencies, but like you have ruby version definition somewhere in your apps code.
Check this files under your projects root folders:
- .rvmrc
- .ruby-version
- .ruby-gemset
- .versions.conf
And also check your Gemfiles for string ruby-2.5.2
.
How to find out which Ruby version an existing Rails project is based on?
If no version-specific gems are in use, I'm not sure it's possible to determine the exact ruby version used during development. In any case, the app may work fine against several versions, depending on the features it has.
If the app has comprehensive tests, you could just work back to find the latest version for which all the tests pass.
Checking the minimum version of Ruby compatible with the Rails version used would also help to narrow the field.
Rails: How does the console decide which Ruby version to use?
Since RUBY_VERSION
returns 2.1.1
you are using Ruby 2.1.1. Probably irb prompt is patched in some way that returns 2.1.0 instead of 2.1.1, I guess by RVM. It should be patched, since standard irb prompt should be something like
irb(main):001:0>
Which ruby version am I using?
If ruby -v
shows 2.6.3, then you are using the ruby which ships with the system by default. You can confirm this in several ways. Running the shell command which ruby
will show /usr/bin/ruby
. Checking your PATH
will show /usr/bin
earlier than the location of the homebrew or rbenv installations.
If you wish to run one of the others, you can put it earlier on the PATH
or invoke it explicitly by giving the fully qualified name such as /usr/local/opt/ruby/bin/ruby myscript.rb
. Another alternative which avoids twiddling the PATH
variable is to use a shebang line at the beginning of different scripts pointing explicitly to the version to use with that script.
Related Topics
How to Invoke an Instance Method on a Ruby Module Without Including It
Rvm Is Not a Function, Selecting Rubies with 'Rvm Use ...' Will Not Work
What's the Difference Between Colon ":" and Fat Arrow "=>"
Where to Define Custom Error Types in Ruby And/Or Rails
How to Run a Single Test in Minitest
Welcome/Home Page in Ruby on Rails - Best Practice
Ubuntu Rails Install Fails on Zlib
Does Ruby Provide a Way to Do File.Read() with Specified Encoding
Keep Form Fields Filled After an Error (Ror)
Has_Many :Through with Counter_Cache
Unexpected Output in Ruby on Rails
Why Do People Say That Ruby Is Slow
Thread Safety: Class Variables in Ruby
Database Configuration Does Not Specify Adapter