RubyGems is a package utility for Ruby (http://rubyforge.org/projects/rubygems). It was written by Jim Weirich. It installs Ruby software packages, and keeps them up to date. It is quite easy to learn and use, even easier than tools like the Unix/Linux tar
utility (http://www.gnu.org/software/tar) or Java's jar
utility (http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/jar.html).
For more information, read the RubyGems documentation at http://docs.rubygems.org. The RubyGems User Guide (http://docs.rubygems.org/read/book/1) gives you most everything you need to know about using RubyGems. There is also a command reference (http://docs.rubygems.org/read/book/2).
If you don't have RubyGems installed, go to Chapter 3 of the RubyGems User Guide at http://rubygems.org/read/chapter/3 for complete installation instructions.
Check to see whether RubyGems is installed:
$ gem --version
0.9.0
$ 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 <COMMAND> show help on COMMAND
(e.g. 'gem help
install')
Further information:
http://rubygems.rubyforge.org
Get a list of RubyGems commands:
$ gem help commands
GEM commands are:
build Build a gem from a gemspec
cert Adjust RubyGems certificate settings
check Check installed gems
cleanup Cleanup old versions of installed gems in
the local repository
contents Display the contents of the installed gems
dependency Show the dependencies of an installed gem
environment Display RubyGems environmental information
help Provide help on the 'gem' command
install Install a gem into the local repository
list Display all gems whose name starts with
STRING
query Query gem information in local or remote
repositories
rdoc Generates RDoc for pre-installed gems
search Display all gems whose name contains STRING
specification Display gem specification (in yaml)
uninstall Uninstall a gem from the local repository
unpack Unpack an installed gem to the current
directory
update Update the named gem (or all installed
gems) in the local repository
For help on a particular command, use 'gem help COMMAND'.
Commands may be abbreviated, so long as they are
unambiguous.
e.g. 'gem i rake' is short for 'gem install rake'.
Get help on a specific RubyGems command:
$ gem help check
Usage: gem check [options]
Options:
-v, --verify FILE Verify gem file against
its internal checksum
-a, --alien Report 'unmanaged' or
rogue files in the gem
repository
-t, --test Run unit tests for gem
-V, --version Specify version for
which to run unit tests
Common Options:
--source URL Use URL as the remote
source for gems
-p, --[no-]http-proxy [URL] Use HTTP proxy for
remote operations
-h, --help Get help on this command
--config-file FILE Use this config file
instead of default
--backtrace Show stack backtrace on
errors
--debug Turn on Ruby debugging
Summary:
Check installed gems
Show RubyGems examples:
$ gem help examples
Some examples of 'gem' usage.
* Install 'rake', either from local directory or remote
server:
gem install rake
* Install 'rake', only from remote server:
gem install rake --remote
* Install 'rake' from remote server, and run unit tests,
and generate RDocs:
gem install --remote rake --test --rdoc --ri
* Install 'rake', but only version 0.3.1, even if
dependencies are not met, and into a specific directory:
gem install rake --version 0.3.1 --force --install-dir
$HOME/.gems
* List local gems whose name begins with 'D':
gem list D
* List local and remote gems whose name contains 'log':
gem search log --both
* List only remote gems whose name contains 'log':
gem search log --remote
* Uninstall 'rake':
gem uninstall rake
* Create a gem:
See http://rubygems.rubyforge.org/wiki/wiki.
pl?CreateAGemInTenMinutes
* See information about RubyGems:
gem environment
List available remote RubyGems packages with the following (drop the --remote
flag to see what you have locally):
$ gem list --remote
*** REMOTE GEMS ***
Need to update 17 gems from http://gems.rubyforge.org
.................
complete
abstract (1.0.0)
a library which enables you to define abstract method in Ruby
ackbar (0.1.1, 0.1.0)
ActiveRecord KirbyBase Adapter
action_profiler (1.0.0)
A profiler for Rails controllers
actionmailer (1.3.3, 1.3.2, 1.3.1, 1.3.0, 1.2.5, 1.2.4,
1.2.3, 1.2.2, 1.2.1, 1.2.0, 1.1.5, 1.1.4, 1.1.3, 1.1.2,
1.1.1, 1.0.1, 1.0.0, 0.9.1, 0.9.0, 0.8.1, 0.8.0, 0.7.1,
0.7.0, 0.6.1, 0.6.0, 0.5.0, 0.4.0, 0.3.0)
Service layer for easy email delivery and testing.
actionpack (1.13.3, 1.13.2, 1.13.1, 1.13.0, 1.12.5,
1.12.4, 1.12.3, 1.12.2, 1.12.1, 1.12.0, 1.11.2, 1.11.1,
1.11.0, 1.10.2, 1.10.1, 1.9.1, 1.9.0, 1.8.1, 1.8.0, 1.7.0,
1.6.0, 1.5.1, 1.5.0, 1.4.0, 1.3.1, 1.3.0, 1.2.0, 1.1.0,
1.0.1, 1.0.0, 0.9.5, 0.9.0, 0.8.5, 0.8.0, 0.7.9, 0.7.8,
0.7.7, 0.7.6, 0.7.5)
Web-flow and rendering framework putting the VC in MVC.
actionservice (0.3.0, 0.2.102, 0.2.100, 0.2.99)
Web service support for Action Pack.
actionwebservice (1.2.3, 1.2.2, 1.2.1, 1.2.0, 1.1.6,
1.1.5, 1.1.4, 1.1.3, 1.1.2, 1.1.1, 1.1.0, 1.0.0, 0.9.4,
0.9.3, 0.9.2, 0.9.1, 0.8.1, 0.8.0, 0.7.1, 0.7.0, 0.6.2,
0.6.1, 0.6.0, 0.5.0)
Web service support for Action Pack.
[truncated]
Install or update Rake (make
à la Ruby, discussed in the next section). You may need root privileges to do this (essentially, you'll need a root password). I use sudo
(http://www.gratisoft.us/sudo) to do this:
$ sudo gem install rake
WARNING: Improper use of the sudo command could lead to
data loss or the deletion of important system files.
Please double-check your typing when using sudo. Type "man
sudo" for more information.
To proceed, enter your password, or type Ctrl-C to abort.
Password:
Bulk updating Gem source index for: http://gems.rubyforge.
org
Successfully installed rake-0.7.2
Installing ri documentation for rake-0.7.2...
Installing RDoc documentation for rake-0.7.2...