Project

General

Profile

Actions

Bug #2336

closed

pathname compare fails in windows

Added by rogerdpack (Roger Pack) over 14 years ago. Updated about 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-10-26 trunk 25491) [i386-mingw32]
Backport:
[ruby-core:26540]

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

Actions #1

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 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

Actions #2

Updated by luislavena (Luis Lavena) over 14 years ago

=begin
On Wed, Nov 4, 2009 at 6:59 PM, Yukihiro Matsumoto 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 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

Actions #3

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, 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

=end

Actions #4

Updated by usa (Usaku NAKAMURA) over 14 years ago

  • Category set to lib
  • Status changed from Open to Rejected

=begin

=end

Actions #5

Updated by djberg96 (Daniel Berger) over 14 years ago

=begin
Luis Lavena wrote:

On Wed, Nov 4, 2009 at 6:59 PM, Yukihiro Matsumoto 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 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

Actions #6

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0