【问题标题】:Bundler is deprecating bundle console in favor of bin/console. Can anyone provide more clarity as to how bin/console should work?Bundler 正在弃用捆绑控制台以支持 bin/console。谁能更清楚地说明 bin/console 应该如何工作?
【发布时间】:2020-06-09 18:14:26
【问题描述】:

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

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

[DEPRECATED] 捆绑控制台将替换为由bundle gem <name> 生成的bin/console

bundler docs里翻来翻去,找到了如下解释:

  • bundle console 将被删除并替换为 bin/console

随着时间的推移,我们发现 bundle console 难以维护,因为每个 用户会想要添加她自己的特定调整。为了 简化维护并减少自行车脱落讨论,我们正在删除 bundle console 命令支持 bin/console 脚本 由 bundle gem 在 gem 生成时创建,用户可以调整到 他们的需求。

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

【问题讨论】:

    标签: ruby-on-rails ruby rubygems bundler


    【解决方案1】:

    这是在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__)
    

    您可以在 ruby​​gems GitHub repo 中看到模板。

    【讨论】:

    • 这正是我所需要的。非常感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 2018-07-03
    • 2018-04-27
    • 1970-01-01
    • 2020-02-27
    • 2018-09-03
    • 2021-09-05
    • 2018-12-24
    • 2020-04-03
    相关资源
    最近更新 更多