Invoking the Ruby Interpreter
The standard C-based Ruby implementation is invoked from the command line like this:
ruby [options] [--]program[arguments]
options is zero or more command-line arguments that affect the operation
of the interpreter. The legal
arguments are described shortly.
program is the name of the file that
holds the Ruby program to be run. If the name of the program begins with
a hyphen, precede it with -- to force
it to be treated as a program name rather than as an option. If you use
a single hyphen as the program name, or omit
program and
arguments altogether, the interpreter will
read program text from standard input.
Finally, arguments is any number of
additional tokens on the command line. These tokens become the elements
of the ARGV array.
The subsections that follow describe the options supported by the
standard C-based Ruby implementation. Note that you may set the
RUBYOPT environment
variable to include any of the -W,
-w, -v, -d,
-I, -r, -K,
-E, and -T options. These will automatically be
applied to every invocation of the interpreter, as if they were
specified on the command line, unless the command line
includes --disable-rubyopt.
Common Options
The following options are probably the most commonly used. Most Ruby implementations can be expected to support these options or to provide a work-alike alternative:
-wThis option enables warnings about deprecated or problematic code and sets
$VERBOSEtotrue. Many Ruby programmers use this option routinely to ensure ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access