【问题标题】:Command for displaying a gem's dependencies?显示 gem 依赖项的命令?
【发布时间】:2010-10-29 21:34:12
【问题描述】:

有没有一个命令告诉你一个 gem 依赖的其他 gem?

另外,有没有办法自动安装 gem 的依赖项?

【问题讨论】:

    标签: ruby rubygems


    【解决方案1】:

    以下信息来自下面链接的 ruby​​gems 命令参考。

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

    您要求的第一个命令是“gem 依赖”。下面是命令说明。

    gem dependency GEMNAME [options]
    
    Options:
    -v, --version VERSION            Specify version of gem to uninstall
    -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
    

    您需要的第二个命令是“gem install”。依赖项会自动安装。请阅读以下命令参考中的引用以获取更多详细信息。

    "gem install" 将安装命名的 宝石。它将尝试本地 安装(即 .gem 文件中的 当前目录),如果失败, 它将尝试下载并 安装最新版本的 你想要的宝石。

    如果一个 gem 被远程安装, 这取决于其他宝石 未安装,然后 gem 将下载 并安装这些,在你拥有之后 确认操作。

    【讨论】:

      【解决方案2】:

      要了解本地安装的 gem:

      $ gem dependency /^rails$/
      Gem rails-4.0.12
        actionmailer (= 4.0.12)
        actionpack (= 4.0.12)
        activerecord (= 4.0.12)
        activesupport (= 4.0.12)
        bundler (>= 1.3.0, < 2.0)
        railties (= 4.0.12)
        sprockets-rails (~> 2.0)
      ...
      

      对于任意宝石:

      $ gem dependency -rv 4.2.7 /^rails$/
      Gem rails-4.2.7
        actionmailer (= 4.2.7)
        actionpack (= 4.2.7)
        actionview (= 4.2.7)
        activejob (= 4.2.7)
        activemodel (= 4.2.7)
        activerecord (= 4.2.7)
        activesupport (= 4.2.7)
        bundler (>= 1.3.0, < 2.0)
        railties (= 4.2.7)
        sprockets-rails (>= 0)
      

      -r 代表--remote-v 代表--version。我正在运行rubygems-3.0.3。从3.1.0 开始,您必须省略正则表达式分隔符:

      $ gem dependency -rv 4.2.7 ^rails$
      ...
      

      【讨论】:

        猜你喜欢
        • 2020-05-07
        • 1970-01-01
        • 1970-01-01
        • 2013-02-10
        • 2015-04-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多