Project

General

Profile

Actions

Bug #14891

closed

Pathname#join has different behaviour to File.join

Added by robotdana (Dana Sherson) over 6 years ago. Updated almost 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
2.6.0-preview2, and before
[ruby-core:87761]
Tags:

Description

Pathname.new('/a').join('/b').to_s
# => "/b"
File.join(Pathname.new('/a'), '/b').to_s
# => "/a/b"

in my case '/b' was in a variable and it wasn't immediately obvious why it wasn't working when I moved to use Pathname

This seems to not be desired behaviour as it's different to File.join, and this case isn't document anywhere.

Can we either change the behaviour to treat the "other" of Pathname#+ as always relative (possibly just removing a leading slash), or add this case to the documentation?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0