Bundler 正在弃用捆绑控制台,取而代之的是 bin/console。谁能更清楚地说明 bin/console 应该如何工作?

Bundler is deprecating bundle console in favor of bin/console. Can anyone provide more clarity as to how bin/console should work?

我有一个非常依赖 bundle console 的自定义 ruby gem。没什么特别或花哨的,只是一个交互式控制台,其中包含由 Gemfile 定义的 gem 集。我们在开发过程中经常使用控制台。

当前,当我 运行 命令时,我收到以下弃用消息:

[DEPRECATED] bundle console will be replaced by bin/console generated by bundle gem <name>

bundler docs 中四处挖掘,我发现了以下解释:

  • The bundle console will be removed and replaced with bin/console.

Over time we found bundle console hard to maintain because every user would want to add her own specific tweaks to it. In order to ease maintenance and reduce bikeshedding discussions, we're removing the bundle console command in favor of a bin/console script created by bundle gem on gem generation that users can tweak to their needs.

哪位有知识的可以提供更详细的解释吗?此 gem 当前没有 bin 目录。我很高兴制作一个,我只是不确定文件中应该包含什么。 运行 bundle gem 如上文所述会引发错误(如预期)。

这是在 bin/console:

处生成的文件
#!/usr/bin/env ruby

require "bundler/setup"
require "(your gem name here)"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require "irb"
IRB.start(__FILE__)

您可以在rubygems中看到模板GitHub repo