Search code examples
rubyrubygems

Command for displaying a gem's dependencies?


Is there a command that tells you the other gems that a gem depends on?

Also, is there a way to auto install the gem's dependencies?


Solution

  • The following information was pulled from the rubygems command reference linked below.

    http://guides.rubygems.org/command-reference/#gem-dependency

    The first command you're asking for is "gem dependency". Below is the command description.

    gem dependency GEMNAME [options]
    
    Options:
    -v, --version VERSION            Specify version of gem to dependency
    -r, --[no-]reverse-dependencies  Include reverse dependencies in the output
    -p, --pipe                       Pipe Format (name --version ver)
    
    Common Options:
        --source URL                 Use URL as the remote source for gems
    -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
    
    Arguments:
    GEMNAME   name of gems to show
    
    Summary:
    Show the dependencies of an installed gem
    
    Defaults:
    --version '> 0' --no-reverse
    

    The second command you'll need is "gem install". Dependencies get installed automatically. Read the quote below from the command reference for more detail.

    "gem install" will install the named gem. It will attempt a local installation (i.e. a .gem file in the current directory), and if that fails, it will attempt to download and install the most recent version of the gem you want.

    If a gem is being installed remotely, and it depends on other gems that are not installed, then gem will download and install those, after you have confirmed the operation.