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

戏子无情 提交于 2021-01-27 12:00:46

问题


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:

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

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

  • 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.

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).


回答1:


This is the file that is generated at 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__)

You can see the template in the rubygems GitHub repo.



来源:https://stackoverflow.com/questions/62289286/bundler-is-deprecating-bundle-console-in-favor-of-bin-console-can-anyone-provid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!