Search code examples
haskellcabalcabal-installgnu-toolchain

How can I work around cabal sandbox build errors on Windows due to path length limitations?


For a while I was mystified about the fact that doing installs/builds in a cabal sandbox often failed on my Windows machine. I eventually figured out that the failures were caused by certain paths exceeding the MAX_PATH limit (paths are effectively limited to 255 characters).

As a specific example, if I try to cabal install data-default-instances-old-locale-0.0.1 within a cabal sandbox folder, it fails. At some point in the process, Cabal invokes ar.exe with a path that looks like dist/dist-sandbox-72eb259b\build\libHSdata-default-instances-old-locale-0.0.1-6jcjjaR25tK4x3nJhHHjFM.a-45644\libHSdata-default-instances-old-locale-0.0.1-6jcjjaR25tK4x3nJhHHjFM.a. This is relative to a working folder under the temp directory (which I have set to simply C:\Temp), so the full path works out to be C:\Temp\data-default-instances-old-locale-0.0.1-18744\data-default-instances-old-locale-0.0.1\dist\dist-sandbox-72eb259b\build\libHSdata-default-instances-old-locale-0.0.1-6jcjjaR25tK4x3nJhHHjFM.a-18744\libHSdata-default-instances-old-locale-0.0.1-6jcjjaR25tK4x3nJhHHjFM.a.

That final path is 272 characters long, well over the 255 limit.

It is possible to deal with longer paths on Windows, but it isn't trivial and in any case, ar doesn't seem to do whatever is necessary to handle them (not surprising since it's just a port of the GNU tool chain).

I have a feeling this is the situation for the foreseeable future, but maybe someone can think of a work around?


Solution

  • This was fixed in the most recent release of cabal-install. Upgrading should solve the problem.