From 0b457ba9fa094c6bf2c908ac51f7a24b5d38a97e Mon Sep 17 00:00:00 2001 From: John Mair Date: Fri, 2 Mar 2012 03:59:27 +1300 Subject: [PATCH] Workaround for rubinius binding __FILE__ bug #1581 * This fix works by storing the actual file in an ivar on the binding * see https://github.com/rubinius/rubinius/issues/1581 --- lib/pry/helpers/command_helpers.rb | 5 +++-- lib/pry/rbx_path.rb | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/pry/helpers/command_helpers.rb b/lib/pry/helpers/command_helpers.rb index 354caf25..2ede8020 100644 --- a/lib/pry/helpers/command_helpers.rb +++ b/lib/pry/helpers/command_helpers.rb @@ -30,9 +30,10 @@ class Pry file = target.eval('__FILE__') line_num = target.eval('__LINE__') if rbx? - if file =~ /__unknown__/ - file = RbxPath.convert_path_to_full(target.variables.method.file.to_s) + if !target.instance_variable_defined?(:@__actual_file__) + target.instance_variable_set(:@__actual_file__, RbxPath.convert_path_to_full(target.variables.method.file.to_s)) end + file = target.instance_variable_get(:@__actual_file__).to_s end [file, line_num] diff --git a/lib/pry/rbx_path.rb b/lib/pry/rbx_path.rb index b3d4fa01..a1e4a817 100644 --- a/lib/pry/rbx_path.rb +++ b/lib/pry/rbx_path.rb @@ -10,6 +10,8 @@ class Pry File.join File.dirname(Rubinius::KERNEL_PATH), path elsif path.start_with?("lib") File.join File.dirname(Rubinius::LIB_PATH), path + else + path end end