Skip to content

Pathname#relative_path_from failing when there are certain unicode characters in the path #3396

@hading

Description

@hading

jruby-9.0.0.0 :007 > x = "joe"
=> "joe"
jruby-9.0.0.0 :008 > y = "joe/⸀䐀攀氀攀琀攀䴀攀/fred"
=> "joe/⸀䐀攀氀攀琀攀䴀攀/fred"
jruby-9.0.0.0 :009 > Pathname.new(y).relative_path_from(Pathname.new(x))
TypeError: no implicit conversion from nil to integer
from org/jruby/RubyString.java:2870:in []' from /services/medusa/.rvm/rubies/jruby-9.0.0.0/lib/ruby/stdlib/pathname.rb:48:inchop_basename'
from /services/medusa/.rvm/rubies/jruby-9.0.0.0/lib/ruby/stdlib/pathname.rb:113:in cleanpath_aggressive' from /services/medusa/.rvm/rubies/jruby-9.0.0.0/lib/ruby/stdlib/pathname.rb:91:incleanpath'
from /services/medusa/.rvm/rubies/jruby-9.0.0.0/lib/ruby/stdlib/pathname.rb:493:in relative_path_from' from (irb):9:in'
from org/jruby/RubyKernel.java:979:in eval' from org/jruby/RubyKernel.java:1292:inloop'
from org/jruby/RubyKernel.java:1099:in catch' from org/jruby/RubyKernel.java:1099:incatch'
from /services/medusa/.rvm/rubies/jruby-9.0.0.0/bin/irb:13:in `'

Here's the MRI version, which works:

2.2.3 :006 > x = "joe"
=> "joe"
2.2.3 :007 > y = "joe/⸀䐀攀氀攀琀攀䴀攀/fred"
=> "joe/⸀䐀攀氀攀琀攀䴀攀/fred"
2.2.3 :008 > Pathname.new(y).relative_path_from(Pathname.new(x))
=> #Pathname:⸀䐀攀氀攀琀攀䴀攀/fred

I discovered this at the same time as issue #3392. They appear to be different problems, though.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions