问题
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 bybundle gem <name>
Digging around in the bundler docs I found the following explanation:
- The
bundle console
will be removed and replaced withbin/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 thebundle console
command in favor of abin/console
script created bybundle 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