-
Notifications
You must be signed in to change notification settings - Fork 141
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
(Originally discovered by @tompng in #575 (comment))
Because IRB overrides the global IRB.conf[:MAIN_CONTEXT] when a new session starts, and doesn't change it back to the previous value when the session exists, IRB doesn't support nested sessions well.
For example:
# test.rb
class Foo
def self.bar
binding.irb
end
end
binding.irbbe ruby test.rb
4: end
5: end
=> 6: binding.irb
irb(main):001:0> irb_context.workspace
=> #<IRB::WorkSpace:0x00000001038f6818 @binding=#<Binding:0x0000000100754760>, @main=main>
irb(main):002:0> Foo.bar
From: test.rb @ line 3 :
1: class Foo
2: def self.bar
=> 3: binding.irb
4: end
5: end
6: binding.irb
irb(Foo):001:0> irb_context.workspace # context of the nested session
=> #<IRB::WorkSpace:0x0000000104ef4160 @binding=#<Binding:0x0000000104ef5e70>, @main=Foo>
irb(Foo):002:0> exit # leaving the nested session
=> nil
irb(main):003:0> irb_context.workspace # <==== The context is not restored
=> #<IRB::WorkSpace:0x0000000104ef4160 @binding=#<Binding:0x0000000104ef5e70>, @main=Foo>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working