Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 259
mindtonic Avatar asked Jun 09 '20 18:06

mindtonic


1 Answers

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.

like image 90
Steve Avatar answered Sep 30 '22 20:09

Steve