cabal icon indicating copy to clipboard operation
cabal copied to clipboard

`v2-build` fails when there are white spaces in path to `ghcup\bin\ghc-pkg.exe`

Open Lev135 opened this issue 3 years ago • 4 comments

Describe the bug cabal v2-build fails to build clean cabal-generated project with library and executable. According to warnings and error message it's seems it (or ghcup) doesn't work correctly with white space in file path. Without library everything works fine. v1-build also work.

To Reproduce

  • make new project with library by cabal init
  • run cabal v2-build

Expected behavior Executable will be successfuly built.

Log

Resolving dependencies...
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
 - test-cabal-0.1.0.0 (lib) (first run)
 - test-cabal-0.1.0.0 (exe:test-cabal) (first run)
Configuring library for test-cabal-0.1.0.0..
Warning: 'extra-lib-dirs: Files\ghcup\msys64\mingw64\lib' directory does not
exist.
Warning: 'extra-lib-dirs: Files\ghcup\msys64\mingw64\lib' directory does not
exist.
Warning: 'include-dirs: Files\ghcup\msys64\mingw64\include' directory does not
exist.
Warning: 'include-dirs: Files\ghcup\msys64\mingw64\include' directory does not
exist.
Preprocessing library for test-cabal-0.1.0.0..
Building library for test-cabal-0.1.0.0..
[1 of 1] Compiling MyLib            ( src\MyLib.hs, D:\dvorkin_lev\Haskell\test-cabal\dist-newstyle\build\x86_64-windows\ghc-8.10.7\test-cabal-0.1.0.0\build\MyLib.o 
)
cabal-3.6.2.0.exe: Failed to build test-cabal-0.1.0.0 (which is required by
exe:test-cabal from test-cabal-0.1.0.0). The failure occurred during the final
install step. The exception was:
dieVerbatim: user error (cabal-3.6.2.0.exe: 'C:\Program
Files\ghcup\bin\ghc-pkg.exe' exited with an
error:
test-cabal-0.1.0.0: Warning: library-dirs: C:\Program doesn't exist or isn't a
directory
test-cabal-0.1.0.0: Warning: dynamic-library-dirs: C:\Program doesn't exist or
isn't a directory
test-cabal-0.1.0.0: Warning: include-dirs: C:\Program doesn't exist or isn't a
directory
test-cabal-0.1.0.0: Warning: include-dirs:
D:\dvorkin_lev\Haskell\test-cabal\Files\ghcup\msys64\mingw64\include doesn't
exist or isn't a directory
test-cabal-0.1.0.0: Warning: include-dirs:
D:\dvorkin_lev\Haskell\test-cabal\dist-newstyle\build\x86_64-windows\ghc-8.10.7\test-cabal-0.1.0.0\build\Files\ghcup\msys64\mingw64\include
doesn't exist or isn't a directory
test-cabal-0.1.0.0: Warning: haddock-interfaces:
D:\dvorkin_lev\Haskell\test-cabal\dist-newstyle\build\x86_64-windows\ghc-8.10.7\test-cabal-0.1.0.0\doc\html\test-cabal\test-cabal.haddock
doesn't exist or isn't a file
test-cabal-0.1.0.0: Warning: haddock-html:
D:\dvorkin_lev\Haskell\test-cabal\dist-newstyle\build\x86_64-windows\ghc-8.10.7\test-cabal-0.1.0.0\doc\html\test-cabal
doesn't exist or isn't a directory
test-cabal-0.1.0.0: library-dirs: Files\ghcup\msys64\mingw64\lib is a relative
path which makes no sense (as there is nothing for it to be relative to). You
can make paths relative to the package database itself by using ${pkgroot}.
(use --force to override)
test-cabal-0.1.0.0: dynamic-library-dirs: Files\ghcup\msys64\mingw64\lib is a
relative path which makes no sense (as there is nothing for it to be relative
to). You can make paths relative to the package database itself by using
${pkgroot}. (use --force to override)
)

System information Operating system Windows 10

cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library

Lev135 avatar Jul 24 '22 19:07 Lev135

Upd. v1-build fails when trying to add extra libraries with similar errors:

mintty-0.1.4-AFZfdEdKJet3r0mUOoGb3u failed during the final install step. The
exception was:
dieVerbatim: user error (cabal-3.6.2.0.exe: 'C:\Program
Files\ghcup\bin\ghc-pkg.exe' exited with an
error:
mintty-0.1.4: Warning: library-dirs: C:\Program doesn't exist or isn't a
directory
mintty-0.1.4: Warning: dynamic-library-dirs: C:\Program doesn't exist or isn't
a directory
mintty-0.1.4: Warning: include-dirs: C:\Program doesn't exist or isn't a
directory
mintty-0.1.4: Warning: haddock-interfaces: C:\Program
Files\cabal\doc\x86_64-windows-ghc-8.10.7\mintty-0.1.4\html\mintty.haddock
doesn't exist or isn't a file
mintty-0.1.4: Warning: haddock-html: C:\Program
Files\cabal\doc\x86_64-windows-ghc-8.10.7\mintty-0.1.4\html doesn't exist or
isn't a directory
mintty-0.1.4: library-dirs: Files\ghcup\msys64\mingw64\lib is a relative path
which makes no sense (as there is nothing for it to be relative to). You can
make paths relative to the package database itself by using ${pkgroot}. (use
--force to override)
mintty-0.1.4: dynamic-library-dirs: Files\ghcup\msys64\mingw64\lib is a
relative path which makes no sense (as there is nothing for it to be relative
to). You can make paths relative to the package database itself by using
${pkgroot}. (use --force to override)
)

Lev135 avatar Jul 24 '22 20:07 Lev135

It seems at least some of the messages come from program ghc-pkg, but I couldn't find a ticket in the ghc bug tracker.

Mikolaj avatar Jul 25 '22 06:07 Mikolaj

Thank you for the bug report Although the bug should be investigated, the immediate workaround is use a short, without spaces directory for installing ghcup (iirc the default in Windows is X:\ghcup, precisely to avoid these kind of issues)

jneira avatar Jul 25 '22 09:07 jneira

Yes I've done so and all works for me now. Thank you

Lev135 avatar Jul 26 '22 21:07 Lev135