Description
Describe the bug
Cabal commands do not work with provided paths when the paths contain white spaces. For example, if the path /home/USERNAME/Cabal Projects/app/Main.hs
is provided instead of the path ./app/Main.hs
or the path /home/USERNAME/cabal-projects/app/Main.hs
, the command does not work. This is an issue for projects with parent directories containing white spaces.
To Reproduce
Steps to reproduce the behavior:
- Create a new directory
Cabal Projects
in the home directory/home/USERNAME
. - Run
cabal init
in theCabal Projects
directory. - Run
cabal v2-repl ./app/Main.hs
. The file should run correctly. - Attempt to run
cabal v2-repl /home/USERNAME/Cabal\ Projects/app/Main.hs
orcabal v2-repl "/home/USERNAME/Cabal Projects/app/Main.hs"
. The command fails with the error message "cabal: Unrecognised target syntax for '/home/USERNAME/Cabal Project/app/Main.hs'." for Cabal3.6.2.0
, and "Error: cabal: Failed extracting script block:{- cabal:
start marker not found" for Cabal3.10.1.0
. - Create a new directory
cabal-projects
in the home directory/home/USERNAME
. - Run
cabal init
in thecabal-projects
directory. - Run
cabal v2-repl ./app/Main.hs
. The file should run correctly. - Run
cabal v2-repl /home/USERNAME/cabal-projects/app/Main.hs
. The file should also run correctly.
Expected behavior
The cabal command should run correctly in both the instance where the directory has no whitespace and the instance where the directory has whitespace in its name.
System information
- Linux, Fedora 37
- Tested with cabal versions
3.6.2.0
and3.10.1.0
- Tested with ghc versions
9.2.5
and9.4.4
Additional context
This problem causes issues with Haskell Language Server as HLS runs cabal commands from the root directory with the format cabal v2-repl "/home/USERNAME/Cabal Projects/app/Main.hs"
in order to work, which causes issues when the intermediate directories have whitespaces.