Project

General

Profile

Actions

Bug #14640

closed

[win32] File.realpath treats a relative path with a drive letter as an absolute path.

Bug #14640: [win32] File.realpath treats a relative path with a drive letter as an absolute path.

Added by nobu (Nobuyoshi Nakada) over 8 years ago. Updated 14 days ago.

Status:
Closed
Assignee:
Target version:
-
[ruby-core:86365]
Tags:

Description

When t exists in the current directory under the drive C:,

File.realpath("c:t") #=> No such file or directory @ realpath_rec - c:/t (Errno::ENOENT)

whereas File.expand_path returns Dir.pwd + "/t".

Updated by naruse (Yui NARUSE) almost 8 years ago Actions #1

  • Target version deleted (2.6)

Updated by hsbt (Hiroshi SHIBATA) over 2 years ago Actions #2

  • Status changed from Open to Assigned

Updated by hsbt (Hiroshi SHIBATA) 14 days ago Actions #3

  • Status changed from Assigned to Closed

Applied in changeset git|a22017a42a13945ce3c9129135ae760c988a1ba9.


[Bug #14640] Fix File.realpath with a drive-relative path

A drive letter without a following separator ("c:t") means a path relative to the current directory of that drive, as File.absolute_path interprets it, not the absolute path "c:/t". A drive-relative basedir is read the same way, "~" stays literal since realpath does not expand home directories, and US-ASCII or ASCII-8BIT input is expanded in the filesystem encoding so that a non-ASCII current directory does not come back as "?".

Co-Authored-By: Claude Opus 5.5

Actions

Also available in: PDF Atom