diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-04-05 11:49:11 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-04-05 11:58:31 +0900 |
commit | ec03d137428f83f7d8819e13cb788fbd7d4e75c7 (patch) | |
tree | 3bcd9a511dfefbc01b29a3574bf07e7d55e64a0f /tool | |
parent | df275179bde5eef92b701789b99e88ae038cdae2 (diff) | |
download | ruby-ec03d137428f83f7d8819e13cb788fbd7d4e75c7.tar.gz |
Fallback if Pathname#relative_path_from fails
It can fail due to different prefixes, e.g., drive letters or UNC
paths on DOSish platform.
Diffstat (limited to 'tool')
-rw-r--r-- | tool/ruby_vm/helpers/dumper.rb | 3 | ||||
-rw-r--r-- | tool/ruby_vm/helpers/scanner.rb | 3 |
2 files changed, 4 insertions, 2 deletions
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 |