Skip to content

Improve Error message for attempting to load an unknown module #9171

Open
@fendor

Description

@fendor

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

$ 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 haskell/haskell-language-server#3695 and haskell/haskell-language-server#3595
Tooling has to make sense of this error message to provide any sensible code actions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions