From: merch-redmine@... Date: 2019-08-10T15:18:50+00:00 Subject: [ruby-core:94250] [Ruby master Bug#10011] Passing a string to Pathname#relative_path_from results in NoMethodError Issue #10011 has been updated by jeremyevans0 (Jeremy Evans). Status changed from Assigned to Closed This was fixed between Ruby 2.5 and 2.6: ``` $ ruby25 -r pathname -e 'p Pathname.new("/usr/bin/cc").relative_path_from("/usr/bin")' Traceback (most recent call last): 1: from -e:1:in `
' /usr/local/lib/ruby/2.5/pathname.rb:508:in `relative_path_from': undefined method `cleanpath' for "/usr/bin":String (NoMethodError) $ ruby26 -r pathname -e 'p Pathname.new("/usr/bin/cc").relative_path_from("/usr/bin")' # ``` ---------------------------------------- Bug #10011: Passing a string to Pathname#relative_path_from results in NoMethodError https://bugs.ruby-lang.org/issues/10011#change-80565 * Author: jacknagel (Jack Nagel) * Status: Closed * Priority: Normal * Assignee: akr (Akira Tanaka) * Target version: * ruby -v: ruby 2.2.0dev (2014-07-05 trunk 46706) [x86_64-darwin13] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- When a string is passed to Pathname#relative_path_from, a NoMethodError is raised. ``` irb(main):001:0> require "pathname" => true irb(main):002:0> Pathname.new("/usr/bin/cc").relative_path_from Pathname.new("/usr/bin") => # irb(main):003:0> Pathname.new("/usr/bin/cc").relative_path_from("/usr/bin") NoMethodError: undefined method `cleanpath' for "/usr/bin":String from /Users/jacknagel/.rubies/ruby-2.2.0/lib/ruby/2.2.0/pathname.rb:493:in `relative_path_from' from (irb):3 from /Users/jacknagel/.rubies/ruby-2.2.0/bin/irb:11:in `
' ``` I think either converting the argument to a Pathname or raising TypeError would be acceptable here. -- https://bugs.ruby-lang.org/ Unsubscribe: