ruby 如何仅从 Gemfile 中查看依赖关系树?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19050654/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 06:12:16  来源:igfitidea点击:

How to see the dependency tree just from Gemfile?

rubygembundler

提问by Mohit Verma

I am getting the following error when doing bundle install

执行时出现以下错误 bundle install

Make sure that `gem install couchbase -v '1.3.3'` succeeds before bundling.

Now, i have not included this gem in the Gemfile, so it's coming from some dependency. How can i figure out which gem is dependent on this couchbase gem?

现在,我没有将这个 gem 包含在Gemfile. 我如何确定哪个 gem 依赖于这个沙发底座 gem?

Since bundle installis failing and I don't have Gemfile.lockto figure out this dependency.

因为bundle install失败了,我不必Gemfile.lock弄清楚这种依赖性。

回答by zrl3dx

gem dependency(with no args) should show you all gems from current Gemfile with their dependencies.

gem dependency(没有参数)应该显示当前 Gemfile 中的所有 gems 及其依赖项。

Edit:

编辑:

You can also do gem dependency -R(or just depinsted of dependency) if you want to find out which gems use specific (or all) gems.

如果您想找出哪些 gem 使用特定(或所有) gem,您也可以这样做gem dependency -R(或只是dep插入dependency)。

For deeper dependencies I'd parse output (regex maybe?) of first gem dependencies, pick gem's names and call gem depon each of them, but that's just a loose idea.

对于更深层次的依赖,我会解析第一个 gem 依赖的输出(可能是正则表达式?),选择 gem 的名称并调用gem dep它们中的每一个,但这只是一个松散的想法。

回答by Paulo Fidalgo

You can also use bundlerto create a dependency graph.

您还可以使用bundler创建依赖关系图。

Install graphviz:

安装graphviz:

gem install ruby-graphviz

and then:

进而:

bundle viz

Here are an example of a newly created Rails app:

下面是一个新创建的 Rails 应用程序的示例:

Rails app dependency graph

Rails 应用程序依赖关系图

You can also play with the options:

您还可以使用以下选项:

bundle help viz