Bug #2336
closedpathname compare fails in windows
Description
=begin
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
'
ref:
http://www.ruby-forum.com/topic/198562#new
Thanks.
-r
=end
Updated by matz (Yukihiro Matsumoto) over 14 years ago
=begin
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.
=end
Updated by luislavena (Luis Lavena) over 14 years ago
=begin
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
=end
Updated by usa (Usaku NAKAMURA) over 14 years ago
=begin
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
=end
Updated by usa (Usaku NAKAMURA) over 14 years ago
- Category set to lib
- Status changed from Open to Rejected
=begin
=end
Updated by djberg96 (Daniel Berger) over 14 years ago
=begin
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
=end
Updated by rogerdpack (Roger Pack) over 14 years ago
=begin
ok ok :)
Pathname.new('/').relative_path_from Pathname.new('/')
thanks for the feedback.
-r
=end