1

I'm trying to install ghc-mod for GHC 8.0.1 on windows/x64. When I try to install ghc-mod via cabal install ghc-mod I get an error saying my C compiler isn't working (it is using the c-compiler bundled with ghc).

Here is the output (of the second time I ran the command. Its basically what the first one says but reduced to the error message):

C:\Users\******>cabal install ghc-mod
Resolving dependencies...
Configuring old-time-1.1.0.3...
Failed to install old-time-1.1.0.3
Build log ( C:\Users\******\AppData\Roaming\cabal\logs\old-time-1.1.0.3.log ):
Configuring old-time-1.1.0.3...
bash.exe: warning: could not find /tmp, please create!
configure: WARNING: unrecognized options: --with-compiler
checking for gcc... C:\PROGRA~1\Haskell Platform\8.0.1\mingw\bin\gcc.exe 
                    ^ I think the error lies here, as you can see the file path is corrupted but I wasn't able to locate the cause for this
checking whether the C compiler works... no
configure: error: in `/cygdrive/c/Users/******/AppData/Local/Temp/cabal-tmp-6084/old-time-1.1.0.3':
configure: error: C compiler cannot create executables
See `config.log' for more details
cabal: Leaving directory 'C:\Users\******\AppData\Local\Temp\cabal-tmp-6084\old-time-1.1.0.3'
cabal: Error: some packages failed to install:
cpphs-1.20.2 depends on old-time-1.1.0.3 which failed to install.
ghc-mod-5.6.0.0 depends on old-time-1.1.0.3 which failed to install.
haskell-src-exts-1.17.1 depends on old-time-1.1.0.3 which failed to install.
hlint-1.9.35 depends on old-time-1.1.0.3 which failed to install.
old-time-1.1.0.3 failed during the configure step. The exception was:
ExitFailure 77

Could you please help me to install ghc-mod or provide any other way of installing it.

I already trieded reinstalling Haskell since I'm just starting off but this didn't make any difference. And YES I added the 3 lines provided on the haskell homepage.

Cooki3Tube
  • 107
  • 1
  • 10
  • What does the `config.log` say? – Alec Dec 04 '16 at 19:17
  • Unfortunatly I don't know where it is located, could you please give me a hint ? – Cooki3Tube Dec 04 '16 at 19:24
  • 1
    On Windows, I'd use stack: http://haskellstack.org/ – arrowd Dec 04 '16 at 19:52
  • Sure, I tried this too, but since stack is built on top of `cabal` I get the same error when running `stack installghc-mod` – Cooki3Tube Dec 04 '16 at 20:44
  • 1
    Try using the --no-system-ghc argument to Stack, which will force it to install its own toolchain instead of using the Haskell Platform toolchain. The next version of Stack will be making that setting the default. – Michael Snoyman Dec 04 '16 at 22:22
  • Thanks for the advice this helped :) – Cooki3Tube Dec 05 '16 at 19:30
  • `C:\PROGRA~1\Haskell Platform\8.0.1\mingw\bin\gcc.exe` -- this isn't a corrupted path. its using the short path facility in windows to be more compatible (https://en.wikipedia.org/wiki/8.3_filename). if by 3 lines you mean step 3 here (https://www.haskell.org/platform/windows.html), pasting how you edited your cabal config file might help since it sure _looks_ like an error from those lines not being in place properly... – sclv Dec 05 '16 at 21:26

1 Answers1

2

I can't know for certain, but thought I'd write an answer with what I think is going on.

The old-time package contains a configure script, which is a Unix shell script used to (surprise!) configure the package. The Cabal build system allows packages to automatically integrate configure, and will run the script for them. On POSIX systems, there's always a shell easily available. However, on Windows, that's not the case. I believe that's the problem you're running into.

Now the tricky part: why don't you have a shell? In theory, the Haskell Platform ships a shell. Well, here are my guesses:

  • For Stack usage, there's a Haskell Platform bug where Stack cannot find the MSYS tools, which include the shell script. Newer versions of Stack work around this bug, but passing in --no-system-ghc tells Stack to ignore any installed toolchain and manage the installation itself, which is more reliable than using HP's copy.
  • For Cabal usage, I'm less certain. I think the HP team decided to require you to use a special batch program to set environment variables correctly, so if you just run cabal install foo from a normal command window, Cabal won't find MSYS and it will fail. However, without more information, I can't be certain this is the case.

My personal recommendation: uninstall Haskell Platform, and use the recommended Stack installation instructions. In your case, that's just downloading and running the 64-bit Windows installer.

Finally: your suspected problem is not actually a problem; on Windows, pathnames longer than 8 characters can be compressed in the way you see (with ~1 at the end). There's nothing buggy in that path display.

Michael Snoyman
  • 31,100
  • 3
  • 48
  • 77