Skip to content

Unable to load modules in haskell-language-server/plugins/default #1394

Open
@berberman

Description

@berberman

HLS version:

haskell-language-server version: 0.9.0.0 (GHC: 8.10.3) (PATH: /home/berberman/.cabal/store/ghc-8.10.3/haskell-language-server-0.9.0.0-fc61519dda1a1498575dccc3fb04c9f3a1600a61493f968ee632374480d5dcd6/bin/haskell-language-server)
Tool versions found on the $PATH
cabal:		3.2.0.0
stack:		Not found
ghc:		8.10.3

I found HLS could not load modules in this directory: for example, I opened Example.hs, and I got

Multi Cradle: No prefixes matched
pwd: /home/berberman/Desktop/haskell/haskell-language-server
filepath: /home/berberman/Desktop/haskell/haskell-language-server/plugins/default/src/Ide/Plugin/Example.hs
prefixes:
("./ghcide/src",Cabal {component = Just "lib:ghcide"})
("./ghcide/session-loader",Cabal {component = Just "lib:ghcide"})
("./ghcide/test/preprocessor/Main.hs",Cabal {component = Just "ghcide:exe:ghcide-test-preprocessor"})
("./ghcide/bench/hist/Main.hs",Cabal {component = Just "ghcide:bench:benchHist"})
("./ghcide/bench/lib/Main.hs",Cabal {component = Just "ghcide:bench:benchHist"})
("./ghcide/bench/hist/Experiments/Types.hs",Cabal {component = Just "ghcide:bench:benchHist"})
("./ghcide/bench/lib/Experiments/Types.hs",Cabal {component = Just "ghcide:bench:benchHist"})
("./ghcide/exe/Main.hs",Cabal {component = Just "ghcide:exe:ghcide"})
("./ghcide/exe/Arguments.hs",Cabal {component = Just "ghcide:exe:ghcide"})
("./ghcide/exe/Paths_ghcide.hs",Cabal {component = Just "ghcide:exe:ghcide"})
("./ghcide/test/cabal",Cabal {component = Just "ghcide:test:ghcide-tests"})
("./ghcide/test/exe",Cabal {component = Just "ghcide:test:ghcide-tests"})
("./ghcide/test/src",Cabal {component = Just "ghcide:test:ghcide-tests"})
("./ghcide/bench/lib",Cabal {component = Just "ghcide:test:ghcide-tests"})
("./ghcide/bench/lib/Main.hs",Cabal {component = Just "ghcide:exe:ghcide-bench"})
("./ghcide/bench/exe/Main.hs",Cabal {component = Just "ghcide:exe:ghcide-bench"})
("./ghcide/bench/lib/Experiments.hs",Cabal {component = Just "ghcide:exe:ghcide-bench"})
("./ghcide/bench/lib/Experiments/Types.hs",Cabal {component = Just "ghcide:exe:ghcide-bench"})
("./ghcide/bench/exe/Experiments.hs",Cabal {component = Just "ghcide:exe:ghcide-bench"})
("./ghcide/bench/exe/Experiments/Types.hs",Cabal {component = Just "ghcide:exe:ghcide-bench"})
("./src",Cabal {component = Just "lib:haskell-language-server"})
("./exe/Main.hs",Cabal {component = Just "haskell-language-server:exe:haskell-language-server"})
("./exe/Plugins.hs",Cabal {component = Just "haskell-language-server:exe:haskell-language-server"})
("./exe/Wrapper.hs",Cabal {component = Just "haskell-language-server:exe:haskell-language-server-wrapper"})
("./test/functional",Cabal {component = Just "haskell-language-server:test:func-test"})
("./plugins/hls-tactics-plugin/src",Cabal {component = Just "haskell-language-server:test:func-test"})
("./plugins/hls-eval-plugin/test",Cabal {component = Just "haskell-language-server:test:func-test"})
("./plugins/hls-splice-plugin/src",Cabal {component = Just "haskell-language-server:test:func-test"})
("./plugins/hls-eval-plugin/src",Cabal {component = Just "haskell-language-server:test:func-test"})
("./test/wrapper",Cabal {component = Just "haskell-language-server:test:wrapper-test"})
("./hie-compat/src-ghc86",Cabal {component = Just "lib:hie-compat"})
("./hie-compat/src-ghc88",Cabal {component = Just "lib:hie-compat"})
("./hie-compat/src-reexport",Cabal {component = Just "lib:hie-compat"})
("./hie-compat/src-ghc810",Cabal {component = Just "lib:hie-compat"})
("./hie-compat/src-reexport",Cabal {component = Just "lib:hie-compat"})
("./hls-plugin-api/src",Cabal {component = Just "lib:hls-plugin-api"})
("./plugins/hls-class-plugin/src",Cabal {component = Just "lib:hls-class-plugin"})
("./plugins/hls-eval-plugin/src",Cabal {component = Just "lib:hls-eval-plugin"})
("./plugins/hls-explicit-imports-plugin/src",Cabal {component = Just "lib:hls-explicit-imports-plugin"})
("./plugins/hls-haddock-comments-plugin/src",Cabal {component = Just "lib:hls-haddock-comments-plugin"})
("./plugins/hls-hlint-plugin/src",Cabal {component = Just "lib:hls-hlint-plugin"})
("./plugins/hls-retrie-plugin/src",Cabal {component = Just "lib:hls-retrie-plugin"})
("./plugins/hls-splice-plugin/src",Cabal {component = Just "lib:hls-splice-plugin"})
("./plugins/hls-tactics-plugin/src",Cabal {component = Just "lib:hls-tactics-plugin"})
("./plugins/hls-tactics-plugin/test",Cabal {component = Just "hls-tactics-plugin:test:tests"})
("./shake-bench/src",Cabal {component = Just "lib:shake-bench"})

The cradles generated by implicit-hie didn't include this file. However,

$ hie-bios debug plugins/default/src/Ide/Plugin/Example.hs

worked without error, and further, after I changed loadImplicitHieCradle to HieBios.loadImplicitCradle at

cradle <- maybe (loadImplicitHieCradle $ addTrailingPathSeparator dir) HieBios.loadCradle hieYaml

and

cradle <- maybe (loadImplicitHieCradle $ addTrailingPathSeparator dir) loadCradle hieYaml

i.e. using hie-bios to load the cradle rather than implicit-hie-cradle, I could load these modules successfully. So I think this should be a bug in implicit-hie. It seems that implicit-hie doesn't support common stanzas, but after normalizing these parts (by running cabal format), the result is still inaccurate:

$ cabal format
$ gen-hie
cradle:
  cabal:
    - path: "./ghcide/src"
      component: "lib:ghcide"

    - path: "./ghcide/session-loader"
      component: "lib:ghcide"

    - path: "./ghcide/test/preprocessor/Main.hs"
      component: "ghcide:exe:ghcide-test-preprocessor"

    - path: "./ghcide/bench/hist/Main.hs"
      component: "ghcide:bench:benchHist"

    - path: "./ghcide/bench/lib/Main.hs"
      component: "ghcide:bench:benchHist"

    - path: "./ghcide/bench/hist/Experiments/Types.hs"
      component: "ghcide:bench:benchHist"

    - path: "./ghcide/bench/lib/Experiments/Types.hs"
      component: "ghcide:bench:benchHist"

    - path: "./ghcide/exe/Main.hs"
      component: "ghcide:exe:ghcide"

    - path: "./ghcide/exe/Arguments.hs"
      component: "ghcide:exe:ghcide"

    - path: "./ghcide/exe/Paths_ghcide.hs"
      component: "ghcide:exe:ghcide"

    - path: "./ghcide/test/cabal"
      component: "ghcide:test:ghcide-tests"

    - path: "./ghcide/test/exe"
      component: "ghcide:test:ghcide-tests"

    - path: "./ghcide/test/src"
      component: "ghcide:test:ghcide-tests"

    - path: "./ghcide/bench/lib"
      component: "ghcide:test:ghcide-tests"

    - path: "./ghcide/bench/lib/Main.hs"
      component: "ghcide:exe:ghcide-bench"

    - path: "./ghcide/bench/exe/Main.hs"
      component: "ghcide:exe:ghcide-bench"

    - path: "./ghcide/bench/lib/Experiments.hs"
      component: "ghcide:exe:ghcide-bench"

    - path: "./ghcide/bench/lib/Experiments/Types.hs"
      component: "ghcide:exe:ghcide-bench"

    - path: "./ghcide/bench/exe/Experiments.hs"
      component: "ghcide:exe:ghcide-bench"

    - path: "./ghcide/bench/exe/Experiments/Types.hs"
      component: "ghcide:exe:ghcide-bench"

    - path: "./src"
      component: "lib:haskell-language-server"

    - path: "./plugins/default/src/Main.hs"
      component: "haskell-language-server:exe:haskell-language-server"

    - path: "./plugins/default/src/Ide/Plugin/Brittany.hs"
      component: "haskell-language-server:exe:haskell-language-server"

    - path: "./exe/Wrapper.hs"
      component: "haskell-language-server:exe:haskell-language-server-wrapper"

    - path: "./test/utils"
      component: "haskell-language-server:test:func-test"

    - path: "./test/functional"
      component: "haskell-language-server:test:func-test"

    - path: "./plugins/hls-tactics-plugin/src"
      component: "haskell-language-server:test:func-test"

    - path: "./plugins/hls-eval-plugin/test"
      component: "haskell-language-server:test:func-test"

    - path: "./plugins/hls-splice-plugin/src"
      component: "haskell-language-server:test:func-test"

    - path: "./plugins/hls-eval-plugin/src"
      component: "haskell-language-server:test:func-test"

    - path: "./test/utils"
      component: "haskell-language-server:test:wrapper-test"

    - path: "./test/wrapper"
      component: "haskell-language-server:test:wrapper-test"

    - path: "./hie-compat/src-ghc86"
      component: "lib:hie-compat"

    - path: "./hie-compat/src-ghc88"
      component: "lib:hie-compat"

    - path: "./hie-compat/src-reexport"
      component: "lib:hie-compat"

    - path: "./hie-compat/src-ghc810"
      component: "lib:hie-compat"

    - path: "./hie-compat/src-reexport"
      component: "lib:hie-compat"

    - path: "./hls-plugin-api/src"
      component: "lib:hls-plugin-api"

    - path: "./plugins/hls-class-plugin/src"
      component: "lib:hls-class-plugin"

    - path: "./plugins/hls-eval-plugin/src"
      component: "lib:hls-eval-plugin"

    - path: "./plugins/hls-explicit-imports-plugin/src"
      component: "lib:hls-explicit-imports-plugin"

    - path: "./plugins/hls-haddock-comments-plugin/src"
      component: "lib:hls-haddock-comments-plugin"

    - path: "./plugins/hls-hlint-plugin/src"
      component: "lib:hls-hlint-plugin"

    - path: "./plugins/hls-retrie-plugin/src"
      component: "lib:hls-retrie-plugin"

    - path: "./plugins/hls-splice-plugin/src"
      component: "lib:hls-splice-plugin"

    - path: "./plugins/hls-tactics-plugin/src"
      component: "lib:hls-tactics-plugin"

    - path: "./plugins/hls-tactics-plugin/test"
      component: "hls-tactics-plugin:test:tests"

    - path: "./shake-bench/src"
      component: "lib:shake-bench"

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: ghcidecomponent: implicit-hiestatus: needs infoNot actionable, because there's missing informationtype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions