From 87958520f3fd7fdec18c3508888b3d2a4e5c27a4 Mon Sep 17 00:00:00 2001 From: takkanm Date: Tue, 19 Jun 2018 20:49:09 +0900 Subject: set real path to __FILE__ and __dir__ in Binding#irb When reading Binding#irb, the file of the calling source is reflected in __FILE__ and __dir__. --- lib/irb.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/irb.rb b/lib/irb.rb index a41d4e13be..522b53f762 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -850,6 +850,8 @@ class Binding IRB.setup(source_location[0], argv: []) workspace = IRB::WorkSpace.new(self) STDOUT.print(workspace.code_around_binding) - IRB::Irb.new(workspace).run(IRB.conf) + binding_irb = IRB::Irb.new(workspace) + binding_irb.context.irb_path = File.expand_path(source_location[0]) + binding_irb.run(IRB.conf) end end -- cgit v1.2.3