Cabal puts builddir on the PATH without escaping colons

Open
#12,620 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
haskell
Domain
build-system

Research direction

Start by searching Cabal's build code for where the --builddir path is added to the module search path, then check how that path is formed on Unix and Windows. Reproduce with the attached package using make build and --builddir=foo:bar; done means the generated module resolves with colon-containing paths on Unix and semicolon-containing paths on Windows.

Written by the indexing model from the issue text.

Description

needs triage type: bug

Describe the bug
Cabal fails to resolve generated modules when the build directory contains :'s. For instance, let's assume we've got a package cabal-builddir-bug, which uses its Paths_cabal_builddir_bug module. Then:

# The following build command works file:
cabal build

# The following build command fails...
cabal build --builddir=foo:bar # fails with:
# ...with:
# <no location info>: error: [GHC-82272]
#     module ‘Paths_cabal_builddir_bug’ cannot be found locally

Presumably, Cabal adds the argument to --builddir to the search path without escaping :'s.

To Reproduce
I've attached a reproducer which comes with a Makefile such that make build runs the failing build command. Steps to reproduce:

  1. Unpack the attached tarball.
  2. Run make build.

cabal-builddir-bug-0.1.0.0.tar.gz

Expected behavior
I'd expect Cabal to escape :'s in the path on Unix systems. Presumably, Cabal should also escape ;'s in the path on Windows.

System information

  • macOS 15
  • Cabal 3.16.1.0
Dominant language
Haskell
Stars
1.8k
Forks
766
Avg merge
5d 21h
Merged PRs (30d)
27

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from haskell/cabal

All issues in haskell/cabal

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.