You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Detect when sh cannot handle Windows short paths #3487
Summary by @ezyang: In a misconfigured msys installation, the default sh in the path may come from cygwin which cannot handle Windows short paths. Unfortunately, Cabal 1.24 switched to using short paths, so using an sh which can handle this is important.
./Setup configure should verify that sh can handle short paths. It's not currently clear what the best way to do this is. It's also possible that cabal-install needs a check too.
Below is the original bug report.
I was having trouble with the configure step for old-time, and decided to compare the behavior of 1.22 and 1.24. 1.22 works fine, but it appears that while 1.24 successfully finds the correct path to gcc, it mangles it when setting CC and invoking the configure script.
...
Using gcc version 5.2.0 found on system at:
C:\Users\hudson\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.1\mingw\bin\gcc.exe
...
"C:\cygwin\bin\sh.exe" "./configure" "--with-compiler=ghc" "--prefix=C:\cygwin\tmp\old-time-1.1.0.3\.cabal-sandbox" "--bindir=$prefix\bin" "--libdir=$prefix" "--libexecdir=$prefix\$libname" "--datadir=$prefix" "--sysconfdir=$prefix\etc" "CC=C:\Users\hudson\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe"
configure:2256: checking for gcc
configure:2283: result: C:\Users\hudson\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe
configure:2512: checking for C compiler version
configure:2521: C:\Users\hudson\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe --version >&5
./configure: line 2523: C:\Users\hudson\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe: command not found
configure:2532: $? = 127
configure:2521: C:\Users\hudson\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe -v >&5
./configure: line 2523: C:\Users\hudson\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe: command not found
configure:2532: $? = 127
configure:2521: C:\Users\hudson\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe -V >&5
./configure: line 2523: C:\Users\hudson\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe: command not found
configure:2532: $? = 127
configure:2521: C:\Users\hudson\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe -qversion >&5
./configure: line 2523: C:\Users\hudson\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe: command not found
configure:2532: $? = 127
configure:2552: checking whether the C compiler works
configure:2574: C:\Users\hudson\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe -fno-stack-protector conftest.c >&5
./configure: line 2576: C:\Users\hudson\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe: command not found
configure:2578: $? = 127
configure:2616: result: no
So cabal is taking a path that does exist and work, and is turning it into one that does not. Is that cabal's fault or is our Windows 10 system configured incorrectly?
The question is why those paths do not work -- i.e. are they not valid short path names or is there a broader issue using short path names, i.e. maybe that the configure script itself can't handle short names for some reason?
Here's a related problem I'm seeing -- as per #2840 we should be using the msys sh, even with cygwin. But somehow the cygwin sh is still being called even though I have "C:\Program Files\Haskell Platform\8.0.1\msys\usr\bin," set as an extra-prog-path in my cabal config file. Was there a regression here?
The same problem arises, alas. It still tries to shorten the path, which on my system doesn't resolve correctly. I also tried with network with the same results, even with the usual --configure-option --host=x86_64-unknown-mingw32 that I have to throw in for successful builds over a Cygwin ssh shell.
I should note that I'm only using Cygwin for the ssh capabilities; the path is configured so that the GHC-bundled mingw tools shadow Cygwin's.
I.e. an invocation of the sh from cygwin. I got the error you described with that. When I ensured I was using the msys sh instead, then the build ran successfully....
Ah, I see what you mean now. I added the /usr/bin subdirectory of Stack's msys installation, and it appears to be using the right sh.exe, although with the same results:
"C:\Users\hudson\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\usr\bin\sh.exe" "./configure" "--with-compiler=ghc" "--prefix=C:\cygwin\tmp\old-time-1.1.0.3\.cabal-sandbox" "--bindir=$prefix\bin" "--libdir=$prefix" "--libexecdir=$prefix\$libname" "--datadir=$prefix" "--sysconfdir=$prefix\etc" "CC=C:\Users\hudson\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe"
configure: WARNING: unrecognized options: --with-compiler
checking for gcc... C:\Users\hudson\AppData\Local\Programs\stack\X86_64~1\GHC-80~1.1\mingw\bin\gcc.exe
checking whether the C compiler works... no
I don't have graphical access to this machine, but I'll put in a ticket to install the new HP and see if the problem persists with that installation.
Okay, using the Haskell Platform and with the suggested modifications to the cabal config, this is now resolved for me. It appears that the short path is still being passed to sh, but the sh bundled with the platform seems to agree with it. I'm fine with closing this ticket unless y'all think there might be some improvements to be made to help people reach a solution.
I don't think the former is very wise, as users should be encouraged to have a proper version of sh lying around (and indeed one comes with the msys tools). The latter seems like a great idea.
I had tried installing msys2 (it was using Git's sh before), the cabal options described by @gbaz and nothing worked. When I changed my PATH back to ghc-7.10.3 everything worked again. Then change to ghc-8.0.1 and everything breaks again.
My solution is even simpler: something, whether it be cabal, ghc, sh or whatever cannot deal with . or - in folder names. Change ghc-8.0.1 to something else (I changed it to just 8), and this incompetence will no longer bother you.
Make sure to change PATH accordingly.
I should not have to go through this effort to get a simple compiler to work.
Activity
ezyang commentedon Jun 9, 2016
Those look like short path names to me. See b946c05
23Skidoo commentedon Jun 9, 2016
Yes, that's on purpose, to work around the issues that Autoconf has with paths that contain spaces. See #3185.
acfoltzer commentedon Jun 9, 2016
From
config.logforold-time:So cabal is taking a path that does exist and work, and is turning it into one that does not. Is that cabal's fault or is our Windows 10 system configured incorrectly?
gbaz commentedon Jun 9, 2016
The question is why those paths do not work -- i.e. are they not valid short path names or is there a broader issue using short path names, i.e. maybe that the configure script itself can't handle short names for some reason?
gbaz commentedon Jun 9, 2016
Here's a related problem I'm seeing -- as per #2840 we should be using the msys sh, even with cygwin. But somehow the cygwin sh is still being called even though I have "C:\Program Files\Haskell Platform\8.0.1\msys\usr\bin," set as an extra-prog-path in my cabal config file. Was there a regression here?
gbaz commentedon Jun 9, 2016
Aha, I had
extra-prog-path: C:\Program Files\Haskell Platform\8.0.1\msys\usr\bin,
C:\Users\gbazerman\AppData\Roaming\cabal\bin
And apparently that format was silently bad.
If we remove the comma and the second element it works and builds for me. @acfoltzer try building with these three lines in your cabal config:
(or the appropriate modifications if your mysys and mingw folders are elsewhere)
acfoltzer commentedon Jun 9, 2016
The same problem arises, alas. It still tries to shorten the path, which on my system doesn't resolve correctly. I also tried with
networkwith the same results, even with the usual--configure-option --host=x86_64-unknown-mingw32that I have to throw in for successful builds over a Cygwin ssh shell.I should note that I'm only using Cygwin for the ssh capabilities; the path is configured so that the GHC-bundled mingw tools shadow Cygwin's.
gbaz commentedon Jun 9, 2016
@acfoltzer I see in your paste above
I.e. an invocation of the
shfrom cygwin. I got the error you described with that. When I ensured I was using the msysshinstead, then the build ran successfully....23Skidoo commentedon Jun 9, 2016
Can confirm that using Cygwin tools can lead to breakage. We should perhaps add a warning about it...
gbaz commentedon Jun 9, 2016
I like the idea of auto-detecting wrong tools and emitting a warning and a suggestion of how to configure things to use the right tools.
acfoltzer commentedon Jun 9, 2016
Ah, I see what you mean now. I added the
/usr/binsubdirectory of Stack's msys installation, and it appears to be using the rightsh.exe, although with the same results:I don't have graphical access to this machine, but I'll put in a ticket to install the new HP and see if the problem persists with that installation.
acfoltzer commentedon Jun 10, 2016
Okay, using the Haskell Platform and with the suggested modifications to the cabal config, this is now resolved for me. It appears that the short path is still being passed to
sh, but theshbundled with the platform seems to agree with it. I'm fine with closing this ticket unless y'all think there might be some improvements to be made to help people reach a solution.23Skidoo commentedon Jun 11, 2016
So I can think of two enhancements:
shand printing a warning.gbaz commentedon Jun 11, 2016
I don't think the former is very wise, as users should be encouraged to have a proper version of sh lying around (and indeed one comes with the msys tools). The latter seems like a great idea.
FPtje commentedon Jul 11, 2016
I had tried installing msys2 (it was using Git's sh before), the cabal options described by @gbaz and nothing worked. When I changed my
PATHback to ghc-7.10.3 everything worked again. Then change toghc-8.0.1and everything breaks again.My solution is even simpler: something, whether it be cabal, ghc, sh or whatever cannot deal with
.or-in folder names. Changeghc-8.0.1to something else (I changed it to just8), and this incompetence will no longer bother you.Make sure to change
PATHaccordingly.I should not have to go through this effort to get a simple compiler to work.
[-]Mangled path to gcc on Windows[/-][+]Detect when sh cannot handle Windows short paths[/+]ezyang commentedon Aug 1, 2016
We've realized that actually there was an unrelated bug in short path computation, reported at #3649. @FPtje I think this was precisely your bug.