Bug #2336
pathname compare fails in windows
| Status: | Rejected | Start date: | 11/05/2009 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | lib | |||
| Target version: | - | |||
| ruby -v: | ruby 1.9.2dev (2009-10-26 trunk 25491) [i386-mingw32] |
Description
>> Pathname.new('c:/').relative_path_from Pathname.new('/')
ArgumentError: different prefix: "c:/" and "/"
from C:/installs/ruby191p243p2/lib/ruby/1.9.1/pathname.rb:742:in
`relative_path_from'
from (irb):4
from C:/installs/ruby191p243p2/bin/irb:12:in `<main>'
ref:
http://www.ruby-forum.com/topic/198562#new
Thanks.
-r
History
Updated by Yukihiro Matsumoto about 2 years ago
Hi, In message "Re: [ruby-core:26540] [Bug #2336] pathname compare fails in windows" on Thu, 5 Nov 2009 04:48:46 +0900, Roger Pack <redmine@ruby-lang.org> writes: |>> Pathname.new('c:/').relative_path_from Pathname.new('/') |ArgumentError: different prefix: "c:/" and "/" Could you tell me what did you expect from above code? For me, Windows ignorant, the error seems natural consequence from #relative_path_from. matz.
Updated by Luis Lavena about 2 years ago
On Wed, Nov 4, 2009 at 6:59 PM, Yukihiro Matsumoto <matz@ruby-lang.org> wrote: > Hi, > > In message "Re: [ruby-core:26540] [Bug #2336] pathname compare fails in windows" > on Thu, 5 Nov 2009 04:48:46 +0900, Roger Pack <redmine@ruby-lang.org> writes: > > |>> Pathname.new('c:/').relative_path_from Pathname.new('/') > |ArgumentError: different prefix: "c:/" and "/" > > Could you tell me what did you expect from above code? > For me, Windows ignorant, the error seems natural consequence from > #relative_path_from. > Even Pathname2 [1], which was conceived as more Windows-friendly version fails with the same error The problem is that '/' should be considering the same drive unit as C:/, or should be considering the current one? (Dir.pwd) [1] http://rubyforge.org/projects/shards/ -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exupéry
Updated by Usaku NAKAMURA about 2 years ago
Hello, In message "[ruby-core:26542] Re: [Bug #2336] pathname compare fails in windows" on Nov.05,2009 06:59:37, <matz@ruby-lang.org> wrote: > |>> Pathname.new('c:/').relative_path_from Pathname.new('/') > |ArgumentError: different prefix: "c:/" and "/" > > Could you tell me what did you expect from above code? > For me, Windows ignorant, the error seems natural consequence from > #relative_path_from. For me, Windows addict, the error seems natural consequence, too. Regards, -- U.Nakamura <usa@garbagecollect.jp>
Updated by Usaku NAKAMURA about 2 years ago
- Category set to lib
- Status changed from Open to Rejected
Updated by Daniel Berger about 2 years ago
Luis Lavena wrote: > On Wed, Nov 4, 2009 at 6:59 PM, Yukihiro Matsumoto <matz@ruby-lang.org> wrote: >> Hi, >> >> In message "Re: [ruby-core:26540] [Bug #2336] pathname compare fails in windows" >> on Thu, 5 Nov 2009 04:48:46 +0900, Roger Pack <redmine@ruby-lang.org> writes: >> >> |>> Pathname.new('c:/').relative_path_from Pathname.new('/') >> |ArgumentError: different prefix: "c:/" and "/" >> >> Could you tell me what did you expect from above code? >> For me, Windows ignorant, the error seems natural consequence from >> #relative_path_from. >> > > Even Pathname2 [1], which was conceived as more Windows-friendly > version fails with the same error I try not to be smarter than the Windows API. From the PathRelativePathTo() documentation: This function takes a pair of paths and generates a relative path from one to the other. The paths do not have to be fully-qualified, but they must have a common prefix, or the function will fail and return FALSE. > The problem is that '/' should be considering the same drive unit as > C:/, or should be considering the current one? (Dir.pwd) Why C? Why not ENV['HOMEDRIVE']? Or the root of the current user's home directory? Or...well, you see where I'm going with this. Regards, Dan
Updated by Roger Pack about 2 years ago
ok ok :)
Pathname.new('/').relative_path_from Pathname.new('/')
thanks for the feedback.
-r