Project

General

Profile

Actions

Bug #10011

closed

Passing a string to Pathname#relative_path_from results in NoMethodError

Added by Anonymous over 10 years ago. Updated over 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.2.0dev (2014-07-05 trunk 46706) [x86_64-darwin13]
[ruby-core:63560]

Description

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")
=> #<Pathname:cc>
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 `<main>'

I think either converting the argument to a Pathname or raising TypeError would be acceptable here.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0