Bundler弃用Bundle控制台,而使用bin/console.谁能提供关于箱/控制台应如何工作的更多说明? [英] Bundler is deprecating bundle console in favor of bin/console. Can anyone provide more clarity as to how bin/console should work?

查看:90
本文介绍了Bundler弃用Bundle控制台,而使用bin/console.谁能提供关于箱/控制台应如何工作的更多说明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a custom ruby gem that relies heavily on bundle console. Nothing special or fancy, just an interactive console with the set of gems defined by the Gemfile included. We use the console a lot during development.

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

Currently when I run the command, I receive the following deprecation message:

[已弃用]捆绑包控制台将替换为 bundle gem< name>

bundler文档中进行挖掘,我发现了以下解释:

Digging around in the bundler docs I found the following explanation:

  • 捆绑控制台将被删除,并替换为 bin/console .
  • The bundle console will be removed and replaced with bin/console.

随着时间的流逝,我们发现捆绑控制台难以维护,因为每个用户想要向其添加自己的特定调整.为了简化维护并减少自行车棚的讨论,我们正在删除使用 bin/console 脚本的 bundle console 命令由 bundle gem 创建于用户可以调整的gem生成上他们的需求.

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 会引发错误(按预期).

Can anyone with knowledge provide a more detailed explanation? This gem currently does not have a bin directory. I'm happy to make one, I'm just not sure what should be in the file. Running bundle gem as described in the note above raises an error (as expected).

推荐答案

这是在 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存储库.

You can see the template in the rubygems GitHub repo.

这篇关于Bundler弃用Bundle控制台,而使用bin/console.谁能提供关于箱/控制台应如何工作的更多说明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆