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

How to determine which gems ship bundled with versions of Ruby

哪些 gems 及其特定版本与 Linux 上的各种 Ruby 版本捆绑在一起?

如何在不安装 Ruby 和 运行 gem list 的每个版本的情况下获得这些信息?任何地方都有此在线清单文件吗?

我猜您要求 gem list --local 以查看已为特定项目安装了哪些 gem。

Ruby 是一种类似于 Python、PERL 或 C# 的语言,但是 gem 是一个 Ruby 库,只是一个 Ruby 脚本某些目的,就像任何其他语言一样,都有库来处理诸如时间对象或可能发出 HTTP 请求之类的事情。

说 "which gems come with a version of Ruby" 对我来说是一个奇怪的要求,因为,特别是在 Linux 上,如果你要从源代码编译 Ruby,你不会有任何 gem秒。您可能只在您的机器上安装了解释器。 Gems 是您拥有 Ruby.

特定版本后必须安装的东西

可能有一些自动安装程序 Linux 软件包会自动安装带有常用 gem 的 Ruby 版本。安装 Ruby 的大多数方法将包括功能 - 正如 TinMan 在评论中指出的那样 - 例如 rubygems - 让你开始。

在 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

这些是我安装的 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

该特定版本还有更多 gem。

只需列出 Ruby 安装版本目录中的文件即可找到所有内容。

Which gems, and their specific versions, ship bundled with various versions of Ruby on Linux?

这实际上并不太依赖于 Ruby 版本,而是依赖于 Ruby 实现。比如在Rubinius中,编译器、解析器、抽象语法树、指令集、标准库都是分开的gems.

而在 YARV 中,解析器和编译器只是整体 VM 的一部分,而标准库只是源代码树的一部分。

How can I this information without having to install each version of Ruby and running gem list? Are there manifest files for this online anywhere?

同样,这在很大程度上取决于实施。

对于 TruffleRuby, you can find the list of bundled gems and default gems in the file versions.json,目前看起来是这样的:

{
  "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"
    }
  }
}

对于YARV源代码中的YARV, you can find the list of bundled gems in the file gems/bundled_gems,目前看起来是这样的:

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

我对 Rubinius 构建系统不是很熟悉,所以我无法为 gem 的列表找到一个简单的位置。我找到了几个,但我认为列表并不详尽:

gems_list.txt in the main Rubinius repository:

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

Rubinius Code 存储库包含用于在 Rubinius 平台上编译和 运行 代码的工具,这些工具用于 Rubinius Ruby 实现。存储库包含以下 gems:

当然,除了所有这些之外,任何 Linux 发行版的 ruby 软件包都可以根据该软件包的维护者的判断,依赖或安装任意数量的还有 gems。