From: hanmac@... Date: 2018-07-03T08:05:40+00:00 Subject: [ruby-core:87763] [Ruby trunk Bug#14891] Pathname#join has different behaviour to File.join Issue #14891 has been updated by Hanmac (Hans Mackowiak). More examples: ~~~ ruby Pathname.new('/a').join('c', 'b').to_s #=> "/a/c/b" Pathname.new('/a').join('/c', 'b').to_s #=> "/c/b" Pathname.new('/a').join('/c', '/b').to_s #=> "/b" ~~~ Why it does this? because `"/c"` means start of an absolute path there ---------------------------------------- Bug #14891: Pathname#join has different behaviour to File.join https://bugs.ruby-lang.org/issues/14891#change-72787 * Author: robotdana (Dana Sherson) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: 2.6.0-preview2, and before * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- ~~~ ruby 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? -- https://bugs.ruby-lang.org/ Unsubscribe: