Issue #13214 has been reported by Ronald Fischer.

----------------------------------------
Bug #13214: FileUtils::mkdir_p creates additional (unrequested) directory on Cygwin
https://bugs.ruby-lang.org/issues/13214

* Author: Ronald Fischer
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-cygwin]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
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)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>