Cabal: Paths with spaces on Windows in the cabal file are not parsed properly

Created on 8 Feb 2015  路  2Comments  路  Source: haskell/cabal

If I add one of the following

  include-dirs: C:\Program Files\MySQL\MySQL Server 5.6\include
  extra-lib-dirs: C:\Program Files\MySQL\MySQL Server 5.6\lib

in my cabal file, it will fail with errors such as Warning: 'include-dirs: 5.6\include' directory does not exist., which looks like the paths are being split on spaces. I've tried adding double quotes around them, but the same thing happens.

I couldn't really find if there's another syntax for specifying paths like this, and I tried cabal-install 1.18 and 1.22, both with the same effect, which is why I'm opening the issue in the cabal repo itself. I've also tried escaping the spaces with \\, but that didn't seem to help either.

windows bug

Most helpful comment

@darthdeus .cabal files can use Haskell string syntax for these cases. So in this case that means using "" and escaping the '\' chars (or using '/' instead).

include-dirs: "C:\\Program Files\\MySQL\\MySQL Server 5.6\\include"
extra-lib-dirs: "C:\\Program Files\\MySQL\\MySQL Server 5.6\\lib"

FYI, this has been the case since pre-1.0 and is documented in the user guide.

Plausibly we could somehow try and warn about this mistake and suggest the correct solution, i.e. string syntax.

All 2 comments

Related to #1634.

@darthdeus .cabal files can use Haskell string syntax for these cases. So in this case that means using "" and escaping the '\' chars (or using '/' instead).

include-dirs: "C:\\Program Files\\MySQL\\MySQL Server 5.6\\include"
extra-lib-dirs: "C:\\Program Files\\MySQL\\MySQL Server 5.6\\lib"

FYI, this has been the case since pre-1.0 and is documented in the user guide.

Plausibly we could somehow try and warn about this mistake and suggest the correct solution, i.e. string syntax.

Was this page helpful?
0 / 5 - 0 ratings