haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

Multi Cradle: No prefixes matched when having `common deps` with no lib.

Open soulomoon opened this issue 3 years ago • 2 comments

Your environment

MacOS

Steps to reproduce

git clone https://github.com/soulomoon/hlsBugExample.git
cd hlsBugExample
haskell-language-server-wrapper

It is really weird, base on different cabal setup.

  • This cause problems:
common deps
  default-language: Haskell2010
  hs-source-dirs:   src
  ghc-options: -Wall
  build-depends:
      base            >=4.12  
executable Main
  import: deps
  main-is: Main.hs

These two works fine:

  • add library lib
    common deps
      default-language: Haskell2010
      hs-source-dirs:   src
      ghc-options: -Wall
      build-depends:
          base            >=4.12  
    
    executable Main
      import: deps
      main-is: Main.hs
    
    library lib
      import: deps
    
  • remove common deps:
    executable Main
      default-language: Haskell2010
      hs-source-dirs:   src
      ghc-options: -Wall
      build-depends:
          base            >=4.12  
      import: deps
      main-is: Main.hs
    

Actual behaviour

  Multi Cradle: No prefixes matched
  pwd: /Users/ares/src/sovioths1
  filepath: /Users/ares/src/sovioths1/src/Main.hs
  prefixes:
  ("./Main.hs",Cabal {component = Just "sovioths:exe:Main"})

Include debug information

No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.7.0.0 aarch64 ghc-9.2.2
Current directory: /Users/ares/src/sovioths1
Operating system: darwin
Arguments: []
Cradle directory: /Users/ares/src/sovioths1
Cradle type: Cabal

Tool versions found on the $PATH
cabal:          3.6.2.0
stack:          2.7.5
ghc:            9.2.2


Consulting the cradle to get project GHC version...
Project GHC version: 9.2.2
haskell-language-server exe candidates: ["haskell-language-server-9.2.2","haskell-language-server"]
Launching haskell-language-server exe at:/Users/ares/.ghcup/bin/haskell-language-server-9.2.2
2022-05-26T09:23:33.116467Z | Info | No log file specified; using stderr.
2022-05-26T09:23:33.116745Z | Info | haskell-language-server version: 1.7.0.0 (GHC: 9.2.2) (PATH: /Users/ares/.ghcup/hls/1.7.0.0/lib/haskell-language-server-1.7.0.0/bin/haskell-language-server-9.2.2)
2022-05-26T09:23:33.117097Z | Info | Directory: /Users/ares/src/sovioths1
2022-05-26T09:23:33.117247Z | Info | Logging heap statistics every 60.00s
 ghcide setup tester in /Users/ares/src/sovioths1.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /Users/ares/src/sovioths1
Found 1 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
  ()

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
2022-05-26T09:23:33.120480Z | Info | Cradle path: src/Main.hs
2022-05-26T09:23:33.120536Z | Warning | No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for src/Main.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.
2022-05-26T09:23:33.123103Z | Info | updateFileDiagnostics published different from new diagnostics - file diagnostics: File:     /Users/ares/src/sovioths1/src/Main.hs
Hidden:   no
Range:    1:1-2:1
Source:   cradle
Severity: DsError
Message: 
  Multi Cradle: No prefixes matched
  pwd: /Users/ares/src/sovioths1
  filepath: /Users/ares/src/sovioths1/src/Main.hs
  prefixes:
  ("./Main.hs",Cabal {component = Just "sovioths:exe:Main"})
Files that failed:
 * /Users/ares/src/sovioths1/src/Main.hs

soulomoon avatar May 26 '22 09:05 soulomoon

This seems like an hie-bios issue, but adding an explicit hie.yaml might do the trick

cradle:
  cabal:
    - path: "./src"
      component: "exe:Main"

eddiemundo avatar May 27 '22 02:05 eddiemundo

It is an issue with implicit-hie https://github.com/Avi-D-coder/implicit-hie/issues/1.

The best fix is to use a simple cabal cradle:

cradle:
  cabal:

Cabal will figure it out in pratically all cases.

fendor avatar May 27 '22 11:05 fendor

Closing due to the demise of implicit-hie-cradle

michaelpj avatar Jan 16 '24 17:01 michaelpj