Improve Error message for attempting to load an unknown module
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the bug**
`cabal repl` and `cabal build` for unknown module displays confusing error message.
```
Error: cabal: Failed extracting script block: `{- cabal:` start marker not
found
```
**To Reproduce**
```sh
$ cabal init -n --lib
# insert the following in the cabal file
$ cat test-cabal-errors
cabal-version: 3.0
name: test-cabal-errors
version: 0.1.0.0
build-type: Simple
library
exposed-modules: MyLib
build-depends: base ^>=4.17.1.0
hs-source-dirs: src
default-language: Haskell2010
$ touch src/Lib.hs
$ cabal repl src/Lib.hs
$ cabal build src/Lib.hs # same error message
```
**Expected behavior**
The error message should convey to the user clearly what is going wrong and why.
Ideally, include information on how to solve the issue. (E.g. "add to exposed-module of some specific component.")
**System information**
- `cabal`: cabal-install version 3.10.1.0
**Additional context**
Related to https://github.com/haskell/haskell-language-server/issues/3695 and https://github.com/haskell/haskell-language-server/issues/3595
Tooling has to make sense of this error message to provide any sensible code actions.
Contributor guide
Research direction
Start by reproducing the failure with `cabal repl src/Lib.hs` and `cabal build src/Lib.hs` using the sample package configuration. Trace how these commands handle an unknown module and improve the resulting message so it explains the problem and how to add the module to an appropriate exposed-modules declaration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100