简体   繁体   English

如何确定哪些 gem 与 Ruby 版本捆绑在一起

[英]How to determine which gems ship bundled with versions of Ruby

Which gems, and their specific versions, ship bundled with various versions of Ruby on Linux?哪些 gem 及其特定版本与 Linux 上的各种版本的 Ruby 捆绑在一起?

How can I this information without having to install each version of Ruby and running gem list ?如何在无需安装 Ruby 的每个版本并运行gem list的情况下获取此信息? Are there manifest files for this online anywhere?是否有任何地方的在线清单文件?

I guess you are asking for gem list --local to see which gems have been installed for a particular project.我猜您是在询问gem list --local以查看已为特定项目安装了哪些 gem。

Ruby is a language like Python, PERL or C#, but a gem is a Ruby library, just a Ruby script that serves some purpose, like any other language has libraries to handle things like Time objects or perhaps making an HTTP request. Ruby is a language like Python, PERL or C#, but a gem is a Ruby library, just a Ruby script that serves some purpose, like any other language has libraries to handle things like Time objects or perhaps making an HTTP request.

Saying "which gems come with a version of Ruby" is a strange request to me, because, specifically on Linux, if you were to compile Ruby from source, you wouldn't have any gems.说“哪些 gem 带有一个 Ruby 版本”对我来说是一个奇怪的要求,因为,特别是在 Linux 上,如果你要从源代码编译 Ruby,你不会有任何 gem。 You would have installed only the interpreter on your machine.您将只在您的机器上安装解释器。 Gems are things that you would have to install once you had a specific version of Ruby.拥有特定版本的 Ruby 后,您必须安装 Gem。

There may be some auto-installer Linux packages that automatically install a version of Ruby with commonly-used gems.可能有一些自动安装程序 Linux 软件包会自动安装带有常用 gem 的 Ruby 版本。 MOST methods to install Ruby will include functionality - as TinMan pointed out in the comments - like rubygems - to get you started.大多数安装 Ruby 的方法将包括功能 - 正如 TinMan 在评论中指出的那样 - 如 rubygems - 让你开始。

On macOS:在 macOS 上:

ls -ltra ~/.rbenv/versions
Apr 27 12:13 2.4.5
Aug 21  2019 2.4.6
Mar  5 06:35 2.5.0
Jan 12 20:57 2.5.3
Oct  4  2019 2.6.3
Feb 11 09:32 2.6.5
Mar  4 22:20 2.7.0

Those are the Ruby versions I installed, and inside each is a folder of gems I installed for each version:这些是我安装的 Ruby 版本,每个版本里面都有一个我为每个版本安装的 gems 文件夹:

ls -l .rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems
actioncable-5.0.7.2  benchmark-ips-2.7.2  excon-0.71.1  io-like-0.3.0  parser-2.7.0.4  recaptcha-5.2.1  sidekiq-6.0.7
actioncable-5.2.4.1  better_errors-2.5.1  execjs-2.7.0  io-like-0.3.1  pg-0.21.0       recaptcha-5.3.0  signet-0.12.0

There are many more gems for that particular version.该特定版本还有更多宝石。

Just list the files in the directory of the installed version of Ruby and you'll find everything.只需列出 Ruby 安装版本目录中的文件,您就会找到所有内容。

Which gems, and their specific versions, ship bundled with various versions of Ruby on Linux?哪些 gem 及其特定版本与 Linux 上的各种版本的 Ruby 捆绑在一起?

This actually does not depend so much on the Ruby version but on the Ruby implementation.这实际上并不太依赖于 Ruby 版本,而是依赖于 Ruby 实现。 For example, in Rubinius, the compiler, the parser, the Abstract Syntax Tree, the Instruction Set, and the standard library are all separate gems.例如,在 Rubinius 中,编译器、解析器、抽象语法树、指令集和标准库都是独立的宝石。

Whereas in YARV, the parser and the compiler are just parts of the monolithic VM, and the standard library is just part of the source tree.而在 YARV 中,解析器和编译器只是整体 VM 的一部分,标准库只是源代码树的一部分。

How can I this information without having to install each version of Ruby and running gem list ?如何在无需安装 Ruby 的每个版本并运行gem list的情况下获取此信息? Are there manifest files for this online anywhere?是否有任何地方的在线清单文件?

Again, this depends heavily on the implementation.同样,这在很大程度上取决于实施。

For TruffleRuby , you can find the list of bundled gems and default gems in the fileversions.json , which currently looks like this:对于TruffleRuby ,您可以在文件versions.json中找到捆绑 gem默认 gem的列表,目前看起来像这样:

{
  "ruby": {
    "version": "2.6.5",
    "revision": 67812
  },

  "gems": {
    "default": {
      "bundler": "1.17.2",
      "gem": "3.0.3",
      "irb": "1.0.0",
      "rake": "12.3.2",
      "rdoc": "6.1.2"
    },

    "bundled": {
      "did_you_mean": "1.3.0",
      "minitest": "5.11.3",
      "net-telnet": "0.2.0",
      "power_assert": "1.1.3",
      "rake": "12.3.2",
      "test-unit": "3.2.9",
      "xmlrpc": "0.3.0"
    }
  }
}

For YARV , you can find the list of bundled gems in the file gems/bundled_gems in the YARV source code, which currently looks like this:对于YARV ,您可以在 YARV 源代码的gems/bundled_gems文件中找到捆绑的 gem 列表,目前看起来像这样:

minitest 5.14.0 https://github.com/seattlerb/minitest
power_assert 1.2.0 https://github.com/ruby/power_assert
rake 13.0.1 https://github.com/ruby/rake
test-unit 3.3.5 https://github.com/test-unit/test-unit
rexml 3.2.4 https://github.com/ruby/rexml
rss 0.2.9 https://github.com/ruby/rss

I am not very familiar with the Rubinius build system, so I was not able to find a simple single location for the list of gems.我对Rubinius构建系统不是很熟悉,所以我无法为 gem 列表找到一个简单的位置。 I found a couple, but I don't think the list is exhaustive:我找到了一对,但我认为列表并不详尽:

gems_list.txt in the main Rubinius repository :主 Rubinius 存储库中的gems_list.txt

bundler-1.16.1.gem
minitest-5.11.1.gem
racc-1.4.14.gem
rake-12.3.0.gem
rb-readline-0.5.5.gem
rdoc-5.1.0.gem

The Rubinius Code repository contains tools to compile and run code on the Rubinius platform, which are used in the Rubinius Ruby implementation. Rubinius 代码存储库包含用于在 Rubinius 平台上编译和运行代码的工具,这些工具用于 Rubinius Ruby 实现。 The repository contains the following gems:该存储库包含以下宝石:

Of course, in addition to all of this, the ruby package of any Linux distribution may, at the discretion of the maintainer of that package, depend on, or install any number of gems as well. Of course, in addition to all of this, the ruby package of any Linux distribution may, at the discretion of the maintainer of that package, depend on, or install any number of gems as well.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM