Monday, December 12, 2016

Installing the Haskell Network library on Windows

Summary: This post describes how to install the Haskell network library on Windows, again.

I recently bought a new computer, and tried to install GHC 8.0.1 then upgrade the network library using Cabal. As I have come to expect, it didn't work. Using Git Bash, I got the error:

$ cabal install network-
Resolving dependencies...
Configuring network-
Failed to install network-
Build log ( C:\Users\Neil\AppData\Roaming\cabal\logs\network- ):
Configuring network-
configure: WARNING: unrecognized options: --with-compiler
checking for gcc... C:\ghc\GHC-80~1.1┼║
checking whether the C compiler works... no
configure: error: in `C:/Neil':
configure: error: C compiler cannot create executables
See `config.log' for more details
cabal: Leaving directory '.'
cabal.exe: Error: some packages failed to install:
old-time- failed during the configure step. The exception was:
ExitFailure 77

Running -v3 shows the CC variable is being set to C:\ghc\GHC-80~1.1┼║, which looks like a buffer corruption or encoding issue. I tried my previous solution, but it didn't work. My new solution is:

$ cabal unpack network-
$ cd network-
$ cabal configure
... fails with a similar error to above ...
$ sh ./configure
$ cabal build
$ cabal copy
$ cabal register

I had to repeat the same pattern for the latest version of old-time, and the same pattern worked.

Another way that works is to use Stack.


niklasl said...

It also works to rename the directory GHC is in from ghc-8.0.1 to something else (say ghc8). Apparently some bug in Haskell's handling of Windows short names is triggered and Cabal used short names for some reason.

Mikhail Glushenkov said...

This is fixed in cabal-install, I just need to upload binaries to the website.