Ruby: Print Version String from Script

By Xah Lee. Date: . Last updated: .

Print version from the command line:

ruby -v

Print version from within a script:

# -*- coding: utf-8 -*-
# Ruby

p RUBY_VERSION # "2.3.7"

Printing version from script is a important technique to find out which version your script is running. Because, you might have several version installed, and and it's harder to find out in terminal, because there are aliases, links, path environment variables, etc effect which Ruby version will start when you type ruby in shell.

Ruby Version Release Dates

Ruby Version Release Dates