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

时间:2021-08-02 20:32:34

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?

我基本上是在大致相当于rpm -V之后 - 这个命令将通过我的一些或所有已安装的gems并确保它们的依赖项也已安装。由于gem install默认安装任何依赖宝石,通常这不是必需的;但是,如果你宝石卸载一个宝石并告诉它继续卸载,即使其他宝石依赖于正在卸载的宝石,那么显然你最终会破坏依赖。问题是,如何在不安装/卸载/更新任何宝石的情况下列出那些破坏的依赖项?

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

注:涉及Bundler的答案对我没什么用处,因为我仍然因为各种原因而被困在Rails 2.x上。

4 个解决方案

#1


5  

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

我知道你说你对Bundler的答案不感兴趣,但......

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.

Bundler将为您处理gem依赖项解析并与Rails 2.3兼容。我使用了许多Rails 2应用程序的Bundler,并没有任何问题。

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

这里有关于在Rails 2.3上安装Bundler的说明:http://gembundler.com/rails23.html

#2


16  

in the bash shell:

在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.

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

#3


3  

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.

你试过运行gem update吗?这将运行所有宝石的所有依赖性测试。您可以运行此命令以安装到单独的目录中。

[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]

[编辑]另外,当你运行gem check时会发生什么? gem依赖项将列出所有gem依赖项。我很确定如果它没有告诉你是否安装了某些东西,你可以将输出传递给命令,例如检查是否安装了这些宝石。 [/编辑]

#4


1  

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.

我绝对同意切换到Bundler的应用程序。如果您正在寻找一种方法来快速识别系统上已安装宝石的未满足的gem依赖关系(就像我一样),那么您可以试试这个脚本。

https://gist.github.com/1124953

https://gist.github.com/1124953

#1


5  

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

我知道你说你对Bundler的答案不感兴趣,但......

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.

Bundler将为您处理gem依赖项解析并与Rails 2.3兼容。我使用了许多Rails 2应用程序的Bundler,并没有任何问题。

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

这里有关于在Rails 2.3上安装Bundler的说明:http://gembundler.com/rails23.html

#2


16  

in the bash shell:

在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.

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

#3


3  

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.

你试过运行gem update吗?这将运行所有宝石的所有依赖性测试。您可以运行此命令以安装到单独的目录中。

[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]

[编辑]另外,当你运行gem check时会发生什么? gem依赖项将列出所有gem依赖项。我很确定如果它没有告诉你是否安装了某些东西,你可以将输出传递给命令,例如检查是否安装了这些宝石。 [/编辑]

#4


1  

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.

我绝对同意切换到Bundler的应用程序。如果您正在寻找一种方法来快速识别系统上已安装宝石的未满足的gem依赖关系(就像我一样),那么您可以试试这个脚本。

https://gist.github.com/1124953

https://gist.github.com/1124953