Ruby/Language Basics/RubyGems

Материал из

Перейти к: навигация, поиск


gem help env

$ gem help env
Usage: gem environment [args] [options]
  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
    -v, --verbose                    Set the verbose level of output
        --config-file FILE           Use this config file instead of default
        --backtrace                  Show stack backtrace on errors
        --debug                      Turn on Ruby debugging
    packageversion  display the package version
    gemdir          display the path where gems are installed
    gempath         display path used to search for gems
    version         display the gem format version
    remotesources   display the remote gem servers
    <omitted>       display everything
    Display RubyGems environmental information

get help on what commands are available (some output truncated).

$ gem help commands
GEM commands are:
 build         Build a gem from a gemspec
 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".

getting help on how to issue RubyGems commands:

$ gem
RubyGems is a sophisticated package manager for Ruby.  This is a
basic help message containing pointers to more information.
    gem -h/--help
    gem -v/--version
    gem command [arguments...] [options...]
    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:

help on examples (some output truncated).

$ 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
* See information about RubyGems:
    gem environment

Let"s check to see if Ruby on Rails is present with the list command.

$ gem list rails
$ gem install rails --include-dependencies

RubyGems is a package utility for Ruby

RubyGems is a package utility for Ruby 
It installs Ruby software packages and keeps them up to date. 
To make sure, type on Unix or Linux:
$ gem -v

Show everything on the RubyGems environment with this command:

$ gem env
Rubygems Environment:
  - VERSION: 0.9.0 (0.9.0)
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
     - /usr/local/lib/ruby/gems/1.8

show the RubyGems installation directory:

$ gem env gemdir

To select dependencies as you install a package, skip the --include-dependencies option

$ gem install rails

To uninstall a package with the uninstall command:

$ gem uninstall rails

To update all the gems on your system with all the current versions, use the update command.

# The --system flag updates the RubyGems system software (some output truncated).
$ gem update --system

You can check what dependencies a gem has with the dependency command:

$ gem dep rails
Gem rails-1.2.3
  rake (>= 0.7.2)
  activesupport (= 1.4.2)
  activerecord (= 1.15.3)
  actionpack (= 1.13.3)
  actionmailer (= 1.3.3)
  actionwebservice (= 1.2.3)