Bug 17167 – dmd fails to write to file or create directory with more than 248 characters in the path
Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2017-02-09T17:58:33Z
Last change time
2022-06-09T14:01:27Z
Assigned to
No Owner
Creator
Atila Neves
Comments
Comment #0 by atila.neves — 2017-02-09T17:58:33Z
I saw this while running dub on Windows:
Error: Error writing file '..\..\..\..\..\..\AppData\Roaming\dub\packages\taggedalgebraic-0.10.5\taggedalgebraic\.dub\build\library-debug-windows-x86-dmd_2073-20BD164B4B4CA7B99E316352127B8128\taggedalgebraic.lib'
If I move the source directory up one directory this stops happening (i.e., dmd would write the output library to '..\..\..\..\..\AppData\Roaming\dub\packages\taggedalgebraic-0.10.5\taggedalgebraic\.dub\build\library-debug-windows-x86-dmd_2073-20BD164B4B4CA7B99E316352127B8128\taggedalgebraic.lib' instead, and successfully)
Comment #1 by atila.neves — 2017-11-01T10:09:48Z
*** Issue 17888 has been marked as a duplicate of this issue. ***
Comment #2 by atila.neves — 2017-11-01T11:26:36Z
After some investigation, it seems that dub specifying relative paths makes it more likely to pass the 248 character limit, since Windows first appends the current absolute path to the relative one. This is a known Windows limitation up until an opt-in in Windows 10 to make the problem go away, and otherwise has to be dealt with by calling the Unicode-aware Win32 file APIs.
Comment #3 by github-bugzilla — 2017-11-15T03:53:59Z
While trying to find the size of a file which was residing in a path more than 300 character length we were getting the error : The system cannot find the path nor the file exist , so does this fix resolve even this issue. In the below example there are 50-60 sub folders.
auto SdFiles = Array!ulong(dirEntries("C:\\Test", SpanMode.depth).map!(a => a.size)).
From,
Vino.B
Comment #7 by atila.neves — 2017-12-22T17:24:22Z
@Vino Probably. Try out with dmd at master and see. If not, please file a new issue.
Comment #8 by vino.bheeman — 2018-04-09T04:01:52Z
Hi All,
As per the issue id 17167 it states that this issue is resolved, but the issue still persist as it tested with DMD32 D Compiler v2.079.1-beta.1 on Windows 2008 R2. so as a temporary solution we have used the UNC path as below
Original Path : C:\Test\1\2\3\4\5\6.............\
UNC Path : \\?\C:\Test\1\2\3\4\5\6.............\
Issue : The appending of UNC path is consuming time and memory as it appends to each file's and folders inside the file system.
Note: The file system is a windows share from Netapp.
May i know when will this be fixed.
From,
Vino.B
Comment #9 by atila.neves — 2018-04-09T13:19:49Z
Have you checked this page?
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
I filed this bug because dub was using relative paths and ended up trying to link to ..\..\..\..\..\Users\%USERNAME%\AppData\Roaming\dub\packages\package-name-version\package-name.
Before the fix, if the dub path with several .. was too large (which happened often), nothing would work. Now, it does.
It's possible that passing in an absolute path is different. I would still say that it's a new bug.
Comment #10 by dlang-bot — 2022-03-17T07:31:43Z
@Geod24 updated dlang/dmd pull request #13828 "Simplify `Module.read` and its interaction with `FileManager`" mentioning this issue:
- Windows: Make FileName.exists correctly work with long path
While attempting to refactor Module.read not to call 'File.read' twice,
test17167 started to fail. The only possible difference was that
the first File.read call was conditional on FileName.exists succeeding,
while the second call was inconditional.
After a bit of research, it turns out that the fix for issue 17167
was apparently missing one key detail (the prefix) to enable long path.
This was not visible at the time because the fix for File.read was complete,
and so the second attempt would succeed, hiding the issue.
https://github.com/dlang/dmd/pull/13828
Comment #11 by dlang-bot — 2022-03-17T11:18:17Z
dlang/dmd pull request #13828 "Simplify `Module.read` and its interaction with `FileManager`" was merged into master:
- 8f2a7b139fa06fe3c36c0598ddc114c331d581f6 by Geod24:
Windows: Make FileName.exists correctly work with long path
While attempting to refactor Module.read not to call 'File.read' twice,
test17167 started to fail. The only possible difference was that
the first File.read call was conditional on FileName.exists succeeding,
while the second call was inconditional.
After a bit of research, it turns out that the fix for issue 17167
was apparently missing one key detail (the prefix) to enable long path.
This was not visible at the time because the fix for File.read was complete,
and so the second attempt would succeed, hiding the issue.
This brings into question the correctness / need for toWStringzThen,
as it's mostly used for long path, and is still being used in cannonicalName.
https://github.com/dlang/dmd/pull/13828