1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fallback if Pathname#relative_path_from fails

It can fail due to different prefixes, e.g., drive letters or UNC
paths on DOSish platform.
This commit is contained in:
Nobuyoshi Nakada 2020-04-05 11:49:11 +09:00
parent df275179bd
commit ec03d13742
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
2 changed files with 4 additions and 2 deletions

View file

@ -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