Wirb.start; IRB.start doesn't activate Wirb inspect mode in IRB
domcleal opened this issue · 3 comments
With Wirb 1.x, the following would launch IRB with the Wirb inspection mode, but it no longer does under Wirb 2.0.0:
require 'irb' require 'wirb' Wirb.start puts "IRB.conf[:INSPECT_MODE] = #{IRB.conf[:INSPECT_MODE].inspect}" puts "IRB.CurrentContext = #{IRB.CurrentContext.inspect}" IRB.start
Wirb.start seems to set IRB.conf correctly, but doesn't change CurrentContext as there isn't one.
$ be ruby test.rb IRB.conf[:INSPECT_MODE] = :wirb IRB.CurrentContext = nil 2.0.0-p353 :001 > IRB => IRB # no colours 2.0.0-p353 :002 > IRB.CurrentContext.inspect_mode => true # should be :wirb?
Only when you run Wirb.start again after starting IRB does the inspect_mode get changed, or if you set IRB.CurrentContext.inspect_mode = :wirb
.
We're using Wirb with Rails, which uses IRB.start to create a new IRB session. To activate Wirb, we add a railtie with a console callback to enable Wirb which executes before the IRB.start, e.g.
Class.new Rails::Railtie do console { Wirb.start } end
@domcleal The Railtie approach works well, does it? I am thinking of adding it to the README as a recommended way (besides using Wirb.start
in .irbrc).
I currently don't see a convenient (monkey-patch free) way of configuring IRB to also start WIRB via IRB.start
Yes, it does. To work around this issue, I created an irbrc file that calls Wirb.start, and changed the Railtie to load the irbrc shipped with the application:
ENV['IRBRC'] = File.expand_path('../irbrc', __FILE__)
Good idea, thank you. (closed)