haskell / haskell/cabal

Misspelled dependency in benchmark causes unhelpful errors

Open
#10,796 1 comment 0 reactions 0 assignees View on GitHub
needs triage re: benchmarks re: error-message type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
If you write an invalid name into the dependencies of a benchmark and run `cabal bench`, it will produce the following error:

> Error: [Cabal-7093]
> Cannot benchmark the package tmp-lme6AnaAzo-0.1.0.0 because none of the components are available to build: the benchmark 'tmp-lme6AnaAzo' is not available because the solver picked a plan that does not include the benchmarks, perhaps because no such plan exists. To see the error message explaining the problems with such plans, force the solver to include the benchmarks for all packages, by adding the line 'tests: True' to the 'cabal.project.local' file.

If you follow the advice and add `tests: True` in the cabal.project.local file, then the error does not change.

If you run `cabal repl tmp-lme6AnaAzo:benchmarks`, it will produce a similarly unhelpful error:

> Error: [Cabal-7076]
> Cannot open a repl for the benchmarks in the package tmp-lme6AnaAzo-0.1.0.0 because none of the components are available to build: the benchmark 'tmp-lme6AnaAzo' is not available because the solver picked a plan that does not include the benchmarks, perhaps because no such plan exists. To see the error message explaining the problems with such plans, force the solver to include the benchmarks for all packages, by adding the line 'tests: True' to the 'cabal.project.local' file.

**To Reproduce**
Steps to reproduce the behavior:

```
$ git clone https://github.com/noughtmare/tmp-lme6AnaAzo
$ cd tmp-lme6AnaAzo
$ cabal bench
$ cabal repl tmp-lme6AnaAzo:benchmarks
```

**Expected behavior**
Ideally, in both cases the error message would immediately produce the real error (which does get produced if you add `benchmarks: True` in the cabal.project.local file):

> Error: [Cabal-7107]
> Could not resolve dependencies:
> [__0] trying: tmp-lme6AnaAzo-0.1.0.0 (user goal)
> [__1] trying: tmp-lme6AnaAzo:*bench
> [__2] unknown package: tmp-lme6AnaAz (dependency of tmp-lme6AnaAzo *bench)
> [__2] fail (backjumping, conflict set: tmp-lme6AnaAz, tmp-lme6AnaAzo, tmp-lme6AnaAzo:bench)
> After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: tmp-lme6AnaAzo, tmp-lme6AnaAzo:bench, tmp-lme6AnaAz

(The problem is that I removed the `o` at the end of the `tmp-lme6AnaAz` dependency name)

But if that is too hard, then I'd at least add to the error message that you should put `benchmarks: True` in your `cabal.project.local` file to force the benchmark to be included.

**System information**
- Operating system: NixOS
- `cabal` 3.14.1.0, `ghc` 9.6.6

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.