Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cabal repl confusing error message for non-exposed module #10215

Open
jforberg opened this issue Jul 19, 2024 · 0 comments
Open

Cabal repl confusing error message for non-exposed module #10215

jforberg opened this issue Jul 19, 2024 · 0 comments

Comments

@jforberg
Copy link

Describe the bug
When working with code, we often wish to open the module we are working with in ghci. The way to do this with cabal is "cabal repl ".

If we forget to include the module in exposed-module we get a quite confusing error message from cabal:

$ cabal repl MyModule.hs
Error: [Cabal-7121]
Failed extracting script block: `{- cabal:` start marker not found

Notably if we drop the ".hs" extension in the filename, we get a much better error message:

$ cabal repl MyModule
Error: [Cabal-7076]
Cannot open a repl for the package MyModule, it is not in this project (either directly or indirectly). If you want to add it to the project then edit the cabal.project file.

I feel the good error message should be used in both situations. Why not just omit the .hs in the name? Well, cabal repl is frequently launched from editor keybinds where finding out the current file name is easy, but finding out the canonical module name can be much harder. And the .hs version does work perfectly as long as the module is in exposed-modules.

To Reproduce
Steps to reproduce the behavior:

Clone this gist and execute "cabal repl MyModule":
https://gist.github.com/jforberg/bcf4debd9be3f37352827765636dc719

Expected behavior
The second error message should be used in both situations.

System information
Arch linux, GHC 9.10.2, Cabal 3.12.1.0.

Additional context
N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant