Search code examples
rubyirbbyebug

IRB called from byebug loses context


When I call IRB from a byebug breakpoint I seem not to be in the expected context. Is this a bug or am I doing something incredibly stupid?

$ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
$ ruby test.rb 
test

[3, 12] in test.rb
    3: 
    4:  def initialize
    5:      @a = "test"
    6:      puts @a
    7:      byebug
=>  8:      puts @a
    9:  end
   10: end
   11: 
   12: Test.new
(byebug) irb
2.2.0 :001 > @a
 => nil 

I'd expect @a to be "test", but it's undefined/nil.


Solution

  • Don't call irb, you can use the byebug prompt in the same way as you'd use IRB.