Skip to content

Wirb.start; IRB.start doesn't activate Wirb inspect mode in IRB #12

@domcleal

Description

@domcleal

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions