haskell / haskell/cabal

Validate `--store-dir` early

Open
#8,791 2 comments 0 reactions 0 assignees View on GitHub
re: error-message re: options re: store-dir
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

If you pass a relative path to `--store-dir`, things will fail, but it is not checked early on, and the error we see finally talks about `--prefix`:
```shell
$ cabal --store-dir=foo install peano-0.1.0.1
...
In order, the following will be built (use -v for more details):
- peano-0.1.0.1 (lib) (requires build)
Configuring library for peano-0.1.0.1..
...
Error: cabal: expected an absolute directory name for --prefix:
foo/ghc-9.4.4/pn-0.1.0.1-84d25fae
```

If we learn lessons from static typing (which is _the thing_ of Haskell), then it is _validate before running_. So:
1. Parse command and options.
2. Validate options.
3. Execute the command.

(I am optimistically labelling this issue as suitable for `newcomer` contributions.)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with `cabal --store-dir=foo install peano-0.1.0.1`, then trace where command options are parsed and validated before execution. Done means a relative `--store-dir` is rejected during early option validation with an error referring to `--store-dir`, rather than failing later as a `--prefix` error.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.