How to Install Ruby; What's RVM, Gem, Rake, Bundler, RDoc, ri, irb?

, , …,

This page shows you how to install Ruby on linux, and explains essential tools used in Ruby. It is NECESSARY to be familiar with these tools if you work with Ruby or Rails. (You might need to reference Ruby Version Release Dates.)

What's “irb”?

“irb” is the interactive command line interface for Ruby.

“irb” is written in Ruby.

Type irb --help. Sample output: irb_help.txt.

Type irb to start. Type exit or press 【Ctrl+d】 to quit.

What's “ri”?

“ri” is Ruby's doc reader, similar to unix man or perl's perldoc or python's pydoc.

“ri” is written in Ruby.

Type ri --help. Sample output: ri_help.txt.

What's “gem”?

RubyGems is a tool for installing/managing Ruby packages. It's similar to linux's apt-get.

Each Ruby package in the RubyGem format is called “gem”. A Ruby package (library) is usually also called a “gem”.

RubyGems is now part of the standard library from Ruby version 1.9.2.

RubyGems is written in Ruby.

The command name is gem. Type gem --version and gem --help. Sample output: gem_help.txt

◆ gem --help
RubyGems is a sophisticated package manager for Ruby.  This is a
basic help message containing pointers to more information.

  Usage:
    gem -h/--help
    gem -v/--version
    gem command [arguments...] [options...]

  Examples:
    gem install rake
    gem list --local
    gem build package.gemspec
    gem help install

  Further help:
    gem help commands            list all 'gem' commands
    gem help examples            show some examples of usage
    gem help platforms           show information about platforms
    gem help <COMMAND>           show help on COMMAND
                                   (⁖ 'gem help install')
    gem server                   present a web page at
                                 http://localhost:8808/
                                 with info about installed gems
  Further information:
    http://rubygems.rubyforge.org

For example, try gem list to list locally installed gems.

What's Rake?

“Rake” is short of “Ruby Make”. Rake (software) is a tool, similar to unix make. It reads a file of dependency spec, and call other commands to build things or run tasks.

Rake is now part of the standard library from Ruby version 1.9.

Rake is written in Ruby.

Type rake --help. Sample output: rake_help.txt

◆ rake --help
rake [-f rakefile] {options} targets...

Options are ...
        --backtrace=[OUT]            Enable full backtrace.  OUT can be stderr (default) or stdout.
        --comments                   Show commented tasks only
        --job-stats [LEVEL]          Display job statistics. LEVEL=history displays a complete job list
        --rules                      Trace the rules resolution.
        --suppress-backtrace PATTERN Suppress backtrace lines matching regexp PATTERN. Ignored if --trace is on.
    -A, --all                        Show all tasks, even uncommented ones
    -D, --describe [PATTERN]         Describe the tasks (matching optional PATTERN), then exit.
    -e, --execute CODE               Execute some Ruby code and exit.
    -E, --execute-continue CODE      Execute some Ruby code, then continue with normal task processing.
    -f, --rakefile [FILE]            Use FILE as the rakefile.
    -G, --no-system, --nosystem      Use standard project Rakefile search paths, ignore system wide rakefiles.
    -g, --system                     Using system wide (global) rakefiles (usually '~/.rake/*.rake').
    -I, --libdir LIBDIR              Include LIBDIR in the search path for required modules.
    -j, --jobs [NUMBER]              Specifies the maximum number of tasks to execute in parallel. (default:2)
    -m, --multitask                  Treat all tasks as multitasks.
    -n, --dry-run                    Do a dry run without executing actions.
    -N, --no-search, --nosearch      Do not search parent directories for the Rakefile.
    -P, --prereqs                    Display the tasks and dependencies, then exit.
    -p, --execute-print CODE         Execute some Ruby code, print the result, then exit.
    -q, --quiet                      Do not log messages to standard output.
    -r, --require MODULE             Require MODULE before executing rakefile.
    -R, --rakelibdir RAKELIBDIR,     Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')
        --rakelib
    -s, --silent                     Like --quiet, but also suppresses the 'in directory' announcement.
    -t, --trace=[OUT]                Turn on invoke/execute tracing, enable full backtrace. OUT can be stderr (default) or stdout.
    -T, --tasks [PATTERN]            Display the tasks (matching optional PATTERN) with descriptions, then exit.
    -v, --verbose                    Log message to standard output.
    -V, --version                    Display the program version.
    -W, --where [PATTERN]            Describe the tasks (matching optional PATTERN), then exit.
    -X, --no-deprecation-warnings    Disable the deprecation warnings.
    -h, -H, --help                   Display this help message.

What's Bundler, bundle?

Bundler is tool similar to RubyGem, except it's specific for a app. That is, it install Ruby packages (gems) specific for your application, based on a dependency file named Gemfile (so, in this respect, it's also similar to Rake or unix “make”). It is heavily used by Rails.

Bundler home page: http://gembundler.com/

Here's a sample Gemfile: Gemfile_sample.txt

The command for Bundler is “bundle”. Type bundle --help.

BUNDLE(1)                                                            BUNDLE(1)

NAME
       bundle - Ruby Dependency Management

SYNOPSIS
       bundle COMMAND [--no-color] [--verbose] [ARGS]

DESCRIPTION
       Bundler  manages  an application's dependencies through its entire life
       across many machines systematically and repeatably.

       See the bundler website http://gembundler.com for information  on  get-
       ting  started,  and Gemfile(5) for more information on the Gemfile for-
       mat.

OPTIONS
       --no-color
              Prints all output without color

       --verbose
              Prints out additional logging information

BUNDLE COMMANDS
       We divide bundle subcommands into primary commands and utilities.

PRIMARY COMMANDS
       bundle install(1) bundle-install.1.html
              Install the gems specified by the Gemfile or Gemfile.lock

       bundle update(1) bundle-update.1.html
              Update dependencies to their latest versions

       bundle package(1) bundle-package.1.html
              Package the .gem files required by  your  application  into  the
              vendor/cache directory

       bundle exec(1) bundle-exec.1.html
              Execute a script in the context of the current bundle

       bundle config(1) bundle-config.1.html
              Specify and read configuration options for bundler

UTILITIES
       bundle check(1)
              Determine  whether  the  requirements  for  your application are
              installed and available to bundler

       bundle list(1)
              Show all of the gems in the current bundle

       bundle show(1)
              Show the source location of a particular gem in the bundle

       bundle outdated(1)
              Show all of the outdated gems in the current bundle

       bundle console(1)
              Start an IRB session in the context of the current bundle

       bundle open(1)
              Open an installed gem in the editor

       bundle viz(1)
              Generate a visual representation of your dependencies

       bundle init(1)
              Generate a simple Gemfile, placed in the current directory

       bundle gem(1)
              Create a simple gem, suitable for development with bundler

       bundle platform(1)
              Displays platform compatibility information

OBSOLETE
       These commands are obsolete and should no longer be used

       o   bundle lock(1)

       o   bundle unlock(1)

       o   bundle cache(1)

Bundler is written in Ruby.

What's RDoc?

Rdoc is Ruby's doc generating tool. Similar to Java's javadoc. It extract class/method names and or special comments from Ruby source code and generate to a output format (⁖ ri format).

Type rdoc --help. Sample output: rdoc_help.txt.

RDoc is written in Ruby.

What's RVM?

RVM is Ruby Version Manager. It is used to install Ruby, and also manage multiple installations of Ruby.

It is recommended that you install Ruby by compiling the source code, or use RVM.

RVM is written in bash.

the command of RVM is rvm.

How to install RVM?

See: How to Install Ruby RVM

blog comments powered by Disqus