显示 gem 依赖项的命令?

问题描述 投票:0回答:2

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

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

ruby rubygems
2个回答
38
投票

以下信息来自下面链接的 rubygems 命令参考。

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

您要求的第一个命令是“gem dependency”。以下是命令说明。

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

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

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

如果正在远程安装 gem, 这取决于其他宝石 未安装,则 gem 会下载 并安装这些,之后你 确认操作。


1
投票

要了解本地安装的 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$
...
© www.soinside.com 2019 - 2024. All rights reserved.