Project

General

Profile

Bug #13214

FileUtils::mkdir_p creates additional (unrequested) directory on Cygwin

Added by rovf (Ronald Fischer) over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-cygwin]
[ruby-core:79529]

Description

FileUtils.mkdir(SOMEPATH) on Cygwin will create a directory ./c: in addition to SOMEPATH, if the following two conditions are met:

-SOMEPATH must be specified as absolute path using Windows drive letters and forward slashes as separators (so called "mixed-mode pathes" in Cygwin technologiy; see man cygpath).

  • The parent directory of SOMEPATH does not exist.

The enclosed zip file demonstrates the problem. To run it, extract it to some directory, cd to this directory and then source the shell script file by typing

. mkdir_test.shell

This script will create a directory c:/tmp, set up everything so that the error can become evident, and the runs mkdir_test.rb. This in turn creates a directory c:/tmp/foo/bar, and shows (using File.exist?), that in addition a director ./c: has been created. If you study the Ruby code, it will be obvious what's going wrong.

My guess is that at one point, FileUtils::mkdir needs to decide whether the path to be created is relative or absolute, and since c:/ is an absolute path only in the realm of Cygwin, but not in Unix, it creates a local directory ./c:. Note however that it does NOT create a full path ./c:/tmp/foo/bar. The requested directory is created as (in Windows notation) C:\TMP\FOO\BAR, as requested, and from this, I conclude, that mkdir_p is, by and large, Cygwin-aware. The error is not that the requested directory was not created, but that this mkdir_p call has created two directories, not one. Indeed, if I pass the path as

FileUtils.mkdir_p('/cygdrive/c/tmp/foo/bar')

everything goes fine.

I can reproduce the error using the 64 Bit version of Cygwin. I don't know whether it also occurs in 32 Bit Cygwin.


Files

mkdir_error_demo.zip (738 Bytes) mkdir_error_demo.zip rovf (Ronald Fischer), 02/14/2017 11:51 AM

Associated revisions

Revision 3261cfd8
Added by nobu (Nobuyoshi Nakada) over 2 years ago

fileutils.rb: do not make root

  • lib/fileutils.rb (FileUtils#mkdir_p): no need to make root directory which should be exist and cannot be made with mkdir recent Cygwin can make a directory contains a colon. [Bug #13214]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 57640
Added by nobu (Nobuyoshi Nakada) over 2 years ago

fileutils.rb: do not make root

  • lib/fileutils.rb (FileUtils#mkdir_p): no need to make root directory which should be exist and cannot be made with mkdir recent Cygwin can make a directory contains a colon. [Bug #13214]

Revision 57640
Added by nobu (Nobuyoshi Nakada) over 2 years ago

fileutils.rb: do not make root

  • lib/fileutils.rb (FileUtils#mkdir_p): no need to make root directory which should be exist and cannot be made with mkdir recent Cygwin can make a directory contains a colon. [Bug #13214]

Revision 57640
Added by nobu (Nobuyoshi Nakada) over 2 years ago

fileutils.rb: do not make root

  • lib/fileutils.rb (FileUtils#mkdir_p): no need to make root directory which should be exist and cannot be made with mkdir recent Cygwin can make a directory contains a colon. [Bug #13214]

Revision acc6a302
Added by usa (Usaku NAKAMURA) over 2 years ago

merge revision(s) 57640: [Backport #13214]

    fileutils.rb: do not make root

    * lib/fileutils.rb (FileUtils#mkdir_p): no need to make root
      directory which should be exist and cannot be made with mkdir
      recent Cygwin can make a directory contains a colon.
      [Bug #13214]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 58120
Added by usa (Usaku NAKAMURA) over 2 years ago

merge revision(s) 57640: [Backport #13214]

fileutils.rb: do not make root

* lib/fileutils.rb (FileUtils#mkdir_p): no need to make root
  directory which should be exist and cannot be made with mkdir
  recent Cygwin can make a directory contains a colon.
  [Bug #13214]

Revision 0dc5e450
Added by nagachika (Tomoyuki Chikanaga) over 2 years ago

merge revision(s) 57640: [Backport #13214]

    fileutils.rb: do not make root

    * lib/fileutils.rb (FileUtils#mkdir_p): no need to make root
      directory which should be exist and cannot be made with mkdir
      recent Cygwin can make a directory contains a colon.
      [Bug #13214]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 58180
Added by nagachika (Tomoyuki Chikanaga) over 2 years ago

merge revision(s) 57640: [Backport #13214]

fileutils.rb: do not make root

* lib/fileutils.rb (FileUtils#mkdir_p): no need to make root
  directory which should be exist and cannot be made with mkdir
  recent Cygwin can make a directory contains a colon.
  [Bug #13214]

Revision 0deee202
Added by nagachika (Tomoyuki Chikanaga) about 2 years ago

merge revision(s) 57640: [Backport #13214]

    fileutils.rb: do not make root

    * lib/fileutils.rb (FileUtils#mkdir_p): no need to make root
      directory which should be exist and cannot be made with mkdir
      recent Cygwin can make a directory contains a colon.
      [Bug #13214]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@58631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 58631
Added by nagachika (Tomoyuki Chikanaga) about 2 years ago

merge revision(s) 57640: [Backport #13214]

fileutils.rb: do not make root

* lib/fileutils.rb (FileUtils#mkdir_p): no need to make root
  directory which should be exist and cannot be made with mkdir
  recent Cygwin can make a directory contains a colon.
  [Bug #13214]

History

#1

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Status changed from Open to Closed

Applied in changeset r57640.


fileutils.rb: do not make root

  • lib/fileutils.rb (FileUtils#mkdir_p): no need to make root directory which should be exist and cannot be made with mkdir recent Cygwin can make a directory contains a colon. [Bug #13214]
#2

Updated by usa (Usaku NAKAMURA) over 2 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED

Updated by usa (Usaku NAKAMURA) over 2 years ago

  • Backport changed from 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: DONE, 2.3: REQUIRED, 2.4: REQUIRED

ruby_2_2 r58120 merged revision(s) 57640.

Updated by nagachika (Tomoyuki Chikanaga) over 2 years ago

  • Backport changed from 2.2: DONE, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: DONE, 2.3: DONE, 2.4: REQUIRED

ruby_2_3 r58180 merged revision(s) 57640.

Updated by nagachika (Tomoyuki Chikanaga) about 2 years ago

  • Backport changed from 2.2: DONE, 2.3: DONE, 2.4: REQUIRED to 2.2: DONE, 2.3: DONE, 2.4: DONE

ruby_2_4 r58631 merged revision(s) 57640.

Also available in: Atom PDF