Skip to content

GHC inconsistently handles \\?\ for long paths on Windows

To demonstrate what I mean first:

>ghc-pkg init \\?\c:\Users\michael\Desktop\some-pkg-db
>dir \\?\c:\Users\Michael\Desktop\some-pkg-db
 Volume in drive \\?\c: is Windows8_OS
 Volume Serial Number is CEF7-874D

 Directory of \\?\c:\Users\Michael\Desktop\some-pkg-db

09/01/2015  09:38 AM    <DIR>          .
09/01/2015  09:38 AM    <DIR>          ..
09/01/2015  09:38 AM                40 package.cache
               1 File(s)             40 bytes
               2 Dir(s)   5,907,509,248 bytes free
>ghc -package-db \\?\c:\Users\Michael\Desktop\some-pkg-db
ghc: can't find a package database at \\?\c:\Users\Michael\Desktop\some-pkg-db

The problem: on Windows by default, paths are limited to 260 characters, which can become a real problem in practice when dealing with the standard library path hierarchy the Cabal library uses and any package with a decent name length. This was a real problem in practice, see:

https://github.com/haskell/cabal/issues/2502

Windows has a workaround for this: you can prefix an absolute path with \\?\, see:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx#maxpath

It would be very useful if such paths worked with GHC, but currently they do not. I don't yet know how deep the problem is.

Trac metadata
Trac field Value
Version 7.10.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information