
#316: on Windows, include paths with spaces not properly passed to c2hs ----------------------------+----------------------------------------------- Reporter: jwlato | Owner: Type: defect | Status: new Priority: normal | Milestone: Component: Cabal library | Version: 1.2.4.0 Severity: normal | Resolution: Keywords: c2hs | Difficulty: normal Ghcversion: 6.8.3 | Platform: Windows ----------------------------+----------------------------------------------- Changes (by duncan): * keywords: include-dirs, c2hs => c2hs Comment: Ok, it turns out to be a c2hs bug, not a Cabal bug. It's not clear from the `build -v` output that we're doing it right, but actually we are! :-) If you run with `-v3` then Cabal logs how it's calling external programs using unambiguous Haskell Show syntax: //(formatted for clarity)// {{{ ("/usr/bin/c2hs" ,["--include=dist/build" ,"--cppopts=-D__GLASGOW_HASKELL__=608" ,"--cppopts=-IC:\\Program Files\\include" ,"--output-dir=dist/build" ,"--output=Test.hs" ,"./Test.chs" ] ) }}} The point is, we are passing "--cppopts=-IC:\\Program Files\\include" as a single argument to c2hs. There's no shell getting in between so that's the actual argument we pass. No escaping is necessary. The problem is that c2hs is not nearly so careful. It calls cpp like so: {{{ let cmd = unwords [cpp, cppOpts, newHeaderFile, ">" ++ preprocFile] exitCode <- system cmd }}} That is, it's using the `system` function. This goes via the system shell so has problems with spaces and escaping. The solution is for us to fix c2hs to use rawSystem as Cabal does. Actually since c2hs needs to capture the output of the command it'll have to use `System.Process.runProcess`. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/316#comment:1 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects