[Hackage] #316: on Windows, include paths with spaces not properly passed to c2hs

#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 | Keywords: include-dirs, c2hs Difficulty: normal | Ghcversion: 6.8.3 Platform: Windows | ----------------------------+----------------------------------------------- On windows, path names with spaces aren't passed to build tools properly. In a new project, with a source file Test.chs and a cabal file with (boilerplate excluded) {{{ #!c exposed-modules: Test build-tools: c2hs include-dirs: "C:\\Program Files\\include" }}} then attempting "runhaskell Setup.lhs build -v" indicates that the following is executed: {{{ #!c c:\Program Files\Haskell\bin\c2hs.exe --include=dist\build --cppopts=-D__GLASGOW_HASKELL__=608 --cppopts=-IC:\Program Files\include --output-dir=dist\build --output=Test.hs Test.chs }}} This command fails because c2hs interprets Files\include as a filename to process. The -IC:\Program Files ... should be quoted to preserve the space in the path. I have attached a test.cabal and Test.chs file that demonstrate the problem. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/316 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#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

#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 ----------------------------+----------------------------------------------- Comment (by duncan): This should be fixed in c2hs-0.16.0, the above test case should be tried again. http://hackage.haskell.org/trac/c2hs/ticket/11 -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/316#comment:2 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#316: on Windows, include paths with spaces not properly passed to c2hs ----------------------------+----------------------------------------------- Reporter: jwlato | Owner: Type: defect | Status: closed Priority: normal | Milestone: Component: Cabal library | Version: 1.2.4.0 Severity: normal | Resolution: fixed Keywords: c2hs | Difficulty: normal Ghcversion: 6.8.3 | Platform: Windows ----------------------------+----------------------------------------------- Changes (by duncan): * status: new => closed * resolution: => fixed Comment: Seems to work now when using c2hs-0.16.0. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/316#comment:3 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects
participants (1)
-
Hackage