Title: os.mkdir fails on UNC network paths
Type: behaviour Severity: major
Components: Library Versions: Jython 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: jeff.allen, nazarlviv07, santa4nt, saynt, zyasoft
Priority: urgent Keywords:

Created on 2014-03-27.19:32:56 by saynt, last changed 2015-03-24.03:44:03 by zyasoft.

msg8264 (view) Author: Rob Jones (saynt) Date: 2014-03-27.19:41:31
os.mkdir() fails with Errno 3 [No such process] when trying to execute on a UNC path of the form r'\\server\share\path\to\dir\to\create'.  This works when the share is mounted to a drive letter and created using a path of the form r'X:\path\to\dir\to\create'.  This may be loosely related to issue #2014.
msg8307 (view) Author: Jeff Allen (jeff.allen) Date: 2014-04-24.22:02:22
I've had a look at this (at first to see if I caused it) and I can see it go wrong. I think maybe the fault is with jnr.posix. A path like "\\MYHOST\Users\Public\test" (to be created) gets as far as this line:
where "//?/" is stuck on the front. I think that would be right for a drive-based path like "C:\Users\Public\test" but here we should be writing "//?/UNC\MYHOST\Users\Public\test".

If I force it to have that value (in the debugger) I find the directory is created.
msg9499 (view) Author: Jim Baker (zyasoft) Date: 2015-02-08.03:40:16
Is this still an issue given the upgrade to JNR Posix 3.0.9?

Another option is to use,%20java.nio.file.attribute.FileAttribute...), which should support setting the desired mode
msg9573 (view) Author: Jim Baker (zyasoft) Date: 2015-03-03.17:21:58
Finally looked into how I could get UNC paths without having to configure any network shares. So these are in fact available, eg, \\localhost\C$\ is the same as C:\ - something probably not surprising to actual Windows users, but I just run Windows in a VM to test Jython on it.

More details here,

So os.listdir(r"\\localhost\C$") works, but not os.mkdir(r"\\localhost\C$\foobaz"). Looks like the solution is to once again use Java NIO2 instead of depending on JNR for such functionality, as I suggested in my previous message (msg9499).
msg9584 (view) Author: Nazar (nazarlviv07) Date: 2015-03-04.08:38:38
Issue #2277 was closed due to duplicate of this issue.
But when I try the simpler case of os.mkdir to see if this is the case I received error (OSError: [Errno 17] File exists). 
So in my case of os.mkdir and os.makedirs we have the same error OSError: [Errno 17] File exists.
Logs are below:
1)In case os.mkdir
OSError: [Errno 17] File exists: '\\\\1.9.83-20150203083249\\docs\\doctrees\\subfolder'
2)In case os.makedirs
  File "\\1.9.83-20150203085148\lib\jython-standalone-2.7-b4.jar\Lib\", line 172, in makedirs
    mkdir(name, mode)
OSError: [Errno 17] File exists: '\\\\1.9.83-20150203085148\\docs\\doctrees\\subfolder'
In both cases folder "subfolder" is not exist before and after execution the program.

Probably issue #2120 and #2277 is not the same.
Correct me if I am wrong.
msg9587 (view) Author: Jim Baker (zyasoft) Date: 2015-03-05.22:24:33
Blocker for RC1, per discussion here

re #2277 os.makedirs simply calls os.mkdir; so long as os.mkdir returns the correct error (errno.EEXIST), it's good. Of course the behavior we are seeing in this bug is that JNR Posix is wrongly returning errno.EEXIST.

Note that the original report of this bug (msg8264), it was returning a different errno, but I suspect that got changed as part of the JNR Posix upgrade.
msg9659 (view) Author: Jim Baker (zyasoft) Date: 2015-03-16.04:41:56
Fixed as of
msg9664 (view) Author: Jim Baker (zyasoft) Date: 2015-03-16.16:02:05
One more fix was required, see

Should be complete now
Date User Action Args
2015-03-24 03:44:03zyasoftsetstatus: pending -> closed
2015-03-16 16:02:05zyasoftsetmessages: + msg9664
2015-03-16 04:41:57zyasoftsetstatus: open -> pending
resolution: accepted -> fixed
messages: + msg9659
2015-03-05 22:24:34zyasoftsetpriority: high -> urgent
messages: + msg9587
2015-03-04 08:38:39nazarlviv07setnosy: + nazarlviv07
messages: + msg9584
2015-03-03 17:22:13zyasoftsetpriority: high
assignee: zyasoft
resolution: remind -> accepted
2015-03-03 17:21:58zyasoftsetmessages: + msg9573
2015-02-13 16:01:39zyasoftsetresolution: remind
2015-02-08 03:40:16zyasoftsetnosy: + zyasoft
messages: + msg9499
2014-04-24 22:02:22jeff.allensetnosy: + jeff.allen
messages: + msg8307
2014-04-01 23:36:04santa4ntsetnosy: + santa4nt
2014-03-27 19:41:31sayntsetmessages: + msg8264
2014-03-27 19:32:56sayntcreate