如何检查已安装的 Ruby gem 的所有依赖项是否都得到满足?

发布于 2024-09-30 23:58:50 字数 394 浏览 0 评论 0原文

我一定错过了一些东西,因为昨晚我惊讶地发现谷歌搜索 check gem dependency 和类似的内容并没有揭示这个问题的答案。

我基本上在寻找大致相当于 rpm -V 的命令,该命令将遍历我安装的一些或所有 gem,并确保它们的依赖项也已安装。由于默认情况下 gem install 会安装任何依赖的 gem,因此通常不需要这样做;但是,如果您gem uninstall一个gem并告诉它继续卸载,即使其他gem依赖于正在卸载的gem,那么显然您最终会遇到损坏的依赖关系。问题是,如何在不安装/卸载/更新任何 gem 的情况下列出那些损坏的依赖项?

注意涉及 Bundler 的答案对我来说没有多大用处,因为由于各种原因我仍然停留在 Rails 2.x 上。

I must be missing something because last night I was astonished to find that googling for check gem dependencies and similar didn't reveal the answer for this.

I'm basically after a rough equivalent of rpm -V - a command that will go through some or all my installed gems and make sure that their dependencies are also installed. Since gem install by default installs any dependent gems, normally this is not necessary; however, if you gem uninstall a gem and tell it to proceed with the uninstall even though other gems depend on the one being uninstalled, then obviously you will end up with broken dependencies. The question is, how do you then list those broken dependencies without installing / uninstalling / updating any gems?

N.B. answers which involve Bundler are not much use to me, since I'm still stuck on Rails 2.x for various reasons.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

放血 2024-10-07 23:58:50

在 bash shell 中:

gem list --no-version > list
gem dependency --pipe > depends
grep -v -f list depends > failed.txt
rm list
rm depends

failed.txt 现在将包含所有未安装的依赖项的列表。

in the bash shell:

gem list --no-version > list
gem dependency --pipe > depends
grep -v -f list depends > failed.txt
rm list
rm depends

failed.txt will now have a list of all dependencies that are not installed.

热情消退 2024-10-07 23:58:50

我知道您说过您对有关 Bundler 的答案不感兴趣,但是……

Bundler 将为您处理 gem 依赖项解析,并且与 Rails 2.3 兼容。我已经将 Bundler 与许多 Rails 2 应用程序一起使用,并且没有遇到任何问题。

这里有安装 Bundler on Rails 2.3 的说明:http://gembundler.com/rails23.html

I know you said you weren't interested in answers about Bundler, but…

Bundler will handle gem dependency resolution for you and is compatible with Rails 2.3. I've used Bundler with a number of Rails 2 apps and not had any problems with it.

There are instructions for installing Bundler on Rails 2.3 here: http://gembundler.com/rails23.html

鱼窥荷 2024-10-07 23:58:50

您是否尝试过运行gem update?这将为您的所有 gem 运行所有依赖项测试。您可以运行它来安装到单独的目录中。

[编辑]
另外,当您运行gem check时会发生什么? gem dependency 将列出所有 gem 依赖项。我很确定,如果它没有告诉您是否安装了某些东西,您可以将输出通过管道传输到像 check 这样的命令,以查看是否安装了这些 gem。
[/编辑]

Have you tried running gem update? That will run all the dependency tests for all of your gems. You can run this to install into a separate directory.

[edit]
Also, what happens when you run gem check? gem dependency will list all gem dependencies. I'm pretty sure that if it doesn't tell you whether something is installed, you could pipe the output to a command like check to see if those gems are installed.
[/edit]

温柔女人霸气范 2024-10-07 23:58:50

我绝对同意切换到 Bundler 来处理应用程序。如果您恰好正在明确寻找一种方法来快速识别系统上已安装 gem 的不满足的 gem 依赖项(就像我一样),那么您可以尝试一下此脚本。

https://gist.github.com/1124953

I definitely agree with switching to Bundler for applications. If you happen to be looking explicitly for a way to quickly identify unsatisfied gem dependencies for installed gems on a system (like I was), then you might give this script a try.

https://gist.github.com/1124953

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文