Skip to content

Forgetting to add modules to cabal leads to confusing "Multi Cradle: No prefixes matched" error #3693

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

Closed
seanhess opened this issue Jul 7, 2023 · 3 comments
Labels

Comments

@seanhess
Copy link
Contributor

seanhess commented Jul 7, 2023

Is your enhancement request related to a problem? Please describe.

I just came back to Haskell after a few years. I'm trying the latest cabal instead of stack this time around, and running into all sorts of confusing problems. See this thread for details.

In short, if you create a new project with cabal, then add a module, you get the "multi-cradle no prefixes matched" error, which doesn't mean anything to me. As a stack/hpack user, I had forgotten that cabal required this, and had no idea what the error message meant. I suspect that any new Haskellers would be equally confused.

In Visual Studio Code it highlights the first line of the second modules and ONLY shows you the following:

Multi Cradle: No prefixes matched
pwd: /Users/sean/Downloads/error-example
filepath: /Users/sean/Downloads/error-example/app/Test.hs
prefixes:
("app/Main.hs",Cabal {component = Just "error-example:exe:error-example"})
cradle

Describe the solution you'd like

I would like HLS to give a clear error message saying that I may have forgotten to add the file to the cabal file.

Note: I have a week off and I'm willing to fix this. I just want to make sure it's something that will be merged, and know about any caveats or potential issues before starting.

Steps to Reproduce

  1. Create a new project with default options
$ cabal --version
cabal-install version 3.10.1.0
compiled using version 3.10.1.0 of the Cabal librar

$ mkdir test && cd test
$ cabal init      # all default options
  1. Add app/Test.hs with the following:
module Test where

test :: IO ()
test = putStrLn "TEST"
  1. Import Test into Main

module Main where

import Test

main :: IO ()
main = do
        putStrLn "Hello, Haskell!"
        Test.test
  1. Run HLS:
$ haskell-language-server-wrapper-2.0.0.1
...
2023-07-07T17:16:41.846129Z | Info | Cradle path: app/Test.hs
2023-07-07T17:16:41.846221Z | Warning | No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for app/Test.hs.
Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).
You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.
2023-07-07T17:16:41.869410Z | Info | invoking build tool to determine build flags (this may take some time depending on the cache)
2023-07-07T17:16:41.871178Z | Info | updateFileDiagnostics published different from new diagnostics - file diagnostics: File:     /Users/sean/Downloads/error-example/app/Test.hs
Hidden:   no
Range:    1:1-2:1
Source:   cradle
Severity: DsError
Message:
  Multi Cradle: No prefixes matched
  pwd: /Users/sean/Downloads/error-example
  filepath: /Users/sean/Downloads/error-example/app/Test.hs
  prefixes:
  ("app/Main.hs",Cabal {component = Just "error-example:exe:error-example"})
@tomjaguarpaw
Copy link
Member

Related: #3585

@michaelpj
Copy link
Collaborator

Also related: #3595

(for the obvious next step, which is having a code action to fix the problem)

@fendor
Copy link
Collaborator

fendor commented Jul 8, 2023

closing in favour of #3695 which tracks the effort and outlines an implementation plan.

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

No branches or pull requests

4 participants