From ec03d137428f83f7d8819e13cb788fbd7d4e75c7 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 5 Apr 2020 11:49:11 +0900 Subject: Fallback if Pathname#relative_path_from fails It can fail due to different prefixes, e.g., drive letters or UNC paths on DOSish platform. --- tool/ruby_vm/helpers/dumper.rb | 3 ++- tool/ruby_vm/helpers/scanner.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'tool/ruby_vm/helpers') diff --git a/tool/ruby_vm/helpers/dumper.rb b/tool/ruby_vm/helpers/dumper.rb index 00c301c01c..98104f4b92 100644 --- a/tool/ruby_vm/helpers/dumper.rb +++ b/tool/ruby_vm/helpers/dumper.rb @@ -25,7 +25,8 @@ class RubyVM::Dumper end def new_erb spec - path = Pathname.new(__FILE__).relative_path_from(Pathname.pwd).dirname + path = Pathname.new(__FILE__) + path = (path.relative_path_from(Pathname.pwd) rescue path).dirname path += '../views' path += spec src = path.read mode: 'rt:utf-8:utf-8' diff --git a/tool/ruby_vm/helpers/scanner.rb b/tool/ruby_vm/helpers/scanner.rb index 593271a415..ef6de8120e 100644 --- a/tool/ruby_vm/helpers/scanner.rb +++ b/tool/ruby_vm/helpers/scanner.rb @@ -20,7 +20,8 @@ class RubyVM::Scanner attr_reader :__LINE__ def initialize path - src = Pathname.new(__FILE__).relative_path_from(Pathname.pwd).dirname + src = Pathname.new(__FILE__) + src = (src.relative_path_from(Pathname.pwd) rescue src).dirname src += path @__LINE__ = 1 @__FILE__ = src.to_path -- cgit v1.2.1