failing cabal install MissingH and network on Wind

2019-09-17 18:00发布

问题:

I just installed a new Haskell version: HaskellPlatform-8.0.1-minimal-x86_64-setup-a, I need the package MissingH, which needs the package network. However cabal install network yields:

$ cabal install network
Resolving dependencies...
cabal: Entering directory 'C:\cygwin64\tmp\cabal-tmp-6136\network-2.6.2.1'
Configuring network-2.6.2.1...
configure: WARNING: unrecognized options: --with-compiler
checking build system type... x86_64-unknown-cygwin
checking host system type... x86_64-unknown-cygwin
checking for gcc... C:\PROGRA~1\HASKEL~1\802E01~1.1\mingw\bin\gcc.exe
checking whether the C compiler works... no
configure: error: in `/tmp/cabal-tmp-6136/network-2.6.2.1':
configure: error: C compiler cannot create executables
See `config.log' for more details
cabal: Leaving directory 'C:\cygwin64\tmp\cabal-tmp-6136\network-2.6.2.1'
Failed to install network-2.6.2.1
cabal.exe: Error: some packages failed to install:
network-2.6.2.1 failed during the configure step. The exception was:
ExitFailure 77

First, I tried to start Cygwin command window as administrator, but that didn't solve the problem. Then, I followed stack cannot build network - where's config.log?

While installing using stack yields success, although I have to run stack setup

$ stack build
Compiler version mismatched, found ghc-8.0.1 (x86_64), but expected minor version match with ghc-7.10.3 (x86_64) (based on resolver setting in C:\tmp\network-2.6.2.1\stack.yaml).
Try running "stack setup" to install the correct GHC into C:\Users\<username>\AppData\Local\Programs\stack\x86_64-windows\

after stack setup, stack build, I get:

$ stack test
network-2.6.2.1: test (suite: regression)

testGetAddrInfo: [OK]

         Test Cases  Total
 Passed  1           1
 Failed  0           0
 Total   1           1

network-2.6.2.1: test (suite: simple)

Basic socket operations:
  testSend: [OK]
  testSendAll: [OK]
  testSendTo: [OK]
  testSendAllTo: [OK]
  testSendMany: [OK]
  testSendManyTo: [OK]
  testRecv: [OK]
  testOverFlowRecv: [OK]
  testRecvFrom: [OK]
  testOverFlowRecvFrom: [OK]
  testUserTimeout: [OK]

         Test Cases  Total
 Passed  11          11
 Failed  0           0
 Total   11          11

Yet still I can't continue with MissingH. In fact, it still tries to install network!

$ cabal install MissingH
Resolving dependencies...
cabal: Entering directory 'C:\cygwin64\tmp\cabal-tmp-5596\network-2.6.2.1'
Configuring network-2.6.2.1...
configure: WARNING: unrecognized options: --with-compiler
checking build system type... x86_64-unknown-cygwin
checking host system type... x86_64-unknown-cygwin
checking for gcc... C:\PROGRA~1\HASKEL~1\802E01~1.1\mingw\bin\gcc.exe
checking whether the C compiler works... no
configure: error: in `/tmp/cabal-tmp-5596/network-2.6.2.1':
configure: error: C compiler cannot create executables
See `config.log' for more details
cabal: Leaving directory 'C:\cygwin64\tmp\cabal-tmp-5596\network-2.6.2.1'
Failed to install network-2.6.2.1

I also tried: http://neilmitchell.blogspot.nl/2010/12/installing-haskell-network-library-on.html which was tested on GHC 6.12.3 and 7.0.1 (and not on the new 8.0.1 version). Unfortunately, I get the error:

getEnv: invalid argument (The operation completed successfully.)

Just for completeness, my cabal version:

$ cabal -V
cabal-install version 1.24.0.0
compiled using version 1.24.0.0 of the Cabal library

What am I missing to install network and MissingH?

回答1:

Stack makes some assumptions about your setup, noteably:

  • ... that it's the only one managing packages on the system
  • ... that it's the only one managing ghc on the system
  • ... that it's the only one managing cabal on the system
  • ... that every project is sandboxed
  • ... that you would rather have stability and predictability than the newest versions of everything

You can get away with using stack together with "plain" tools - but only in different projects and if you're really careful. Things like differing versions of cabal-install can still trip it up. At the same time it keeps its own data separated so installing anything via stack is invisible to cabal. Thus you have two choices: Either have your project buy into stack completely or ditch it completely.

If you want to use it, just add MissingH to your .cabal file and rebuild and everything should be fine. If errors do pop up, the easiest solution is to purge the local cabal repository and try again. If that doesn't work, purge the whole platform and have stack reinstall everything itself and try again. Stack is a picky diva, but once she's on stage she runs it. Tip: if you like the cabal interface but choose to use stack you can always run stuff like stack exec -- cabal install MissingH.

The other option is to ditch stack completely. Uninstall it and use cabal alone, possibly with sandboxes. That still leaves you with the original problem - which looks like a native library is missing that you have to install separately. I have no idea which one it is in this specific case, but I can give you a few hints where to look. If you find no documentation about it, you can just look into the stack files. (they succeeded, after all) But the simplest option is to just look which networking libraries cygwin installed and have it also install the -dev versions of them. They are almost always the right ones.



回答2:

The problem seems to be this

configure: error: in `/tmp/cabal-tmp-6136/network-2.6.2.1':

configure: error: C compiler cannot create executables

Either you don't have a C compiler installed or it's too old. We don't actually support Cygwin anymore, try installing msys2 (actually doesn't platform come with this now?) and compiling via that.

You'll have to install a C compiler as well pacman -S mingw-w64-$(uname -m)-gcc should do. The ./configure scripts won't be able to detect GHC's inplace GCC I think. Not sure as I haven't used platform in a while.