haskell / haskell/cabal

cabal-install generates a confusing error message

Open
#9,045 7 comments 0 reactions 0 assignees View on GitHub
blocked: ghc blocked: upstream re: error-message
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
If a source tries to import modules that are available from another version of package the project already depends on the error message cabal-install generates is extremely confusing:

```
app/Main.hs:4:1: error:
Could not load module ‘Language.LSP.Types’
It is a member of the hidden package ‘lsp-types-1.6.0.0’.
Perhaps you need to add ‘lsp-types’ to the build-depends in your .cabal file.
It is a member of the hidden package ‘lsp-types-1.6.0.0’.
Perhaps you need to add ‘lsp-types’ to the build-depends in your .cabal file.
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
4 | import Language.LSP.Types
| ^^^^^^^^^^^^^^^^^^^^^^^^^
Error: cabal: Failed to build exe:bad-cabal from bad-cabal-0.1.0.0.
```

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

```
$ git clone https://github.com/ddrone/cabal-issue-repro
$ cd cabal-issue-repro
$ cabal v2-build
```

**Expected behavior**
I would prefer in this scenario to not have any package suggestions at all, but the other option would be to check during the error message generation to see whether the dependency is already there, and if it is, to display which version of the package it actually resolves to.

**System information**

```
$ cabal --version
cabal-install version 3.10.1.0
compiled using version 3.10.1.0 of the Cabal library
```

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.