Skip to content

Cabal commands do not work with whitespace in path #8875

Closed
@hua-en

Description

@hua-en

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:

  1. Create a new directory Cabal Projects in the home directory /home/USERNAME.
  2. Run cabal init in the Cabal Projects directory.
  3. Run cabal v2-repl ./app/Main.hs. The file should run correctly.
  4. Attempt to run cabal v2-repl /home/USERNAME/Cabal\ Projects/app/Main.hs or cabal 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 Cabal 3.6.2.0, and "Error: cabal: Failed extracting script block: {- cabal: start marker not found" for Cabal 3.10.1.0.
  5. Create a new directory cabal-projects in the home directory /home/USERNAME.
  6. Run cabal init in the cabal-projects directory.
  7. Run cabal v2-repl ./app/Main.hs. The file should run correctly.
  8. 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 and 3.10.1.0
  • Tested with ghc versions 9.2.5 and 9.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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions