Project

General

Profile

Actions

Bug #1266

closed

relative_path broken on windows

Added by cfis (Charlie Savage) over 15 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2dev (2009-03-06) [i386-mswin32_90]
Backport:
[ruby-core:22829]

Description

=begin
pwd = Pathname.new("C:/Development/src/ruby_trunk/test/minitest")
basedir = Pathname.new("c:/Development/ruby-1.9.1/usr/lib/ruby/1.9.1/mini")
basedir.relative_path_from(pwd)

ArgumentError: different prefix: "c:/" and "C:/Development/src/ruby_trunk/test/minitest"
from c:/Development/ruby/lib/ruby/1.8/pathname.rb:709:in `relative_path_from'

This breaks running the ruby tests on windows.
=end


Files

pathname.patch (977 Bytes) pathname.patch cfis (Charlie Savage), 03/28/2009 05:38 PM
Actions #1

Updated by cfis (Charlie Savage) over 15 years ago

=begin
I was hoping we could raise the priority of this issue. This bug prevents Ruby's test suite from being run at all on windows:

:\Development\src\ruby_trunk\test>ruby runner.rb minitest\test_mini_test.rb
c:/Development/ruby-1.9.1/usr/lib/ruby/1.9.1/pathname.rb:790:in relative_path_from': different prefix: "c:/" and "C:/Development/src/ruby_trunk/test" (ArgumentError) from C:/Development/src/ruby_trunk/test/minitest/test_mini_test.rb:33:in class:TestMiniTest'
from C:/Development/src/ruby_trunk/test/minitest/test_mini_test.rb:16:in <top (required)>' from c:/Development/ruby-1.9.1/usr/lib/ruby/1.9.1/test/unit.rb:55:in require'
from c:/Development/ruby-1.9.1/usr/lib/ruby/1.9.1/test/unit.rb:55:in block in setup_argv' from c:/Development/ruby-1.9.1/usr/lib/ruby/1.9.1/test/unit.rb:49:in each'
from c:/Development/ruby-1.9.1/usr/lib/ruby/1.9.1/test/unit.rb:49:in setup_argv' from runner.rb:9:in '

The issues is that relative path is using case-sensitive comparisons. That's right on Linux, wrong on Windows. For whatever reason on Windows FILE returns c:.. while Dir.pwd returns C:.. And thus the problem.

I've attahced a proposed patch. If on windows (detecting mswin or mingw) then the comparison uses casecmp instead of ==. This seems like it would also apply on OS X when having a case-insensitive HFS+ drive.
=end

Actions #2

Updated by nobu (Nobuyoshi Nakada) over 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r23093.
=end

Actions #3

Updated by cfis (Charlie Savage) over 15 years ago

=begin
Thanks Nobu - looks great. I didn't know about the File::FNM_SYSCASE constant.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0