haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.69k stars 366 forks source link

`Could not load module` error in test suites with custom build type #4366

Closed mb2a-sgn closed 2 months ago

mb2a-sgn commented 3 months ago

Your environment

I prepared a small project to reproduce the issue. (Nix Flakes are required)

my-lib.tar.gz

Which OS do you use? NixOS on WSL2

Which version of GHC do you use and how did you install it? GHC 9.2.8 from Nix Flakes

Which LSP client (editor/plugin) do you use? VS Code + Haskell plugin Which version of HLS do you use and how did you install it? 2.4.0.0 from Nix Flakes

Have you configured HLS in any way (especially: a hie.yaml file)? No.

Steps to reproduce

Prerequisites: Nix Flakes

From CLI: (reproduce the issue probabilistically)

  1. cd to the project root.
  2. nix develop
  3. haskell-language-server-wrapper src/Lib.hs test/Spec.hs

From VS Code:

  1. cd to the project root.
  2. nix develop
  3. Launch VS Code by code .
  4. Open test/Spec.hs and wait for the language server to start. At this point, there should be no errors.
  5. Open src/Lib.hs.

Expected behaviour

No compile errors are reported

Actual behaviour

Could not load module 'Lib' in test/Spec.hs.

The tricky part is that no errors occur when only one of Lib.hs or Spec.hs was opened, but once Lib.hs is opened, errors start appearing in Spec.hs.

Debug information

The following is logs when haskell-language-server-wrapper src/Lib.hs test/Spec.hs failed. (Here, haskell-language-server-wrapper is configured with Nix to use --debug --logfile hls.log. This setting exists because arguments cannot be passed to the Haskell language server from VS Code.)

``` $ haskell-language-server-wrapper src/Lib.hs test/Spec.hs No 'hie.yaml' found. Try to discover the project type! Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 2.4.0.0 x86_64 ghc-9.2.8 Current directory: /home/mb2a-sgn/tmp/my-lib.bak Operating system: linux Arguments: ["src/Lib.hs","test/Spec.hs","--logfile","hls.log","--debug"] Cradle directory: /home/mb2a-sgn/tmp/my-lib.bak Cradle type: Cabal Tool versions found on the $PATH cabal: 3.10.2.1 stack: Not found ghc: 9.2.8 Consulting the cradle to get project GHC version... 2024-07-24T02:18:58.946283Z | Debug | executing command: cabal exec -v0 -- ghc --print-libdir 2024-07-24T02:18:59.514797Z | Debug | executing command: cabal exec -v0 -- ghc -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath) 2024-07-24T02:18:59.892947Z | Debug | executing command: cabal --builddir=/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8 v2-exec --with-compiler /home/mb2a-sgn/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/mb2a-sgn/.cache/hie-bios/ghc-pkg-dd5225e92f03fc6c222db1b166e462a5 ghc -v0 -- --numeric-version Project GHC version: 9.2.8 haskell-language-server exe candidates: ["haskell-language-server-9.2.8","haskell-language-server"] Launching haskell-language-server exe at:/nix/store/42dx51plmzznhfb3666ni0c7wvcmq3n9-my-hls/bin/haskell-language-server-9.2.8 2024-07-24T02:19:00.465163Z | Debug | executing command: cabal exec -v0 -- ghc --print-libdir 2024-07-24T02:19:00.593370Z | Debug | executing command: cabal exec -v0 -- ghc -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath) 2024-07-24T02:19:00.769397Z | Debug | executing command: cabal --builddir=/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8 v2-exec --with-compiler /home/mb2a-sgn/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/mb2a-sgn/.cache/hie-bios/ghc-pkg-dd5225e92f03fc6c222db1b166e462a5 ghc -v0 -- -v0 -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath) 2024-07-24T02:19:00.965364Z | Debug | executing command: cabal exec -v0 -- ghc --print-libdir 2024-07-24T02:19:01.103955Z | Debug | executing command: cabal exec -v0 -- ghc -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath) 2024-07-24T02:19:01.289506Z | Debug | executing command: cabal --builddir=/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8 v2-exec --with-compiler /home/mb2a-sgn/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/mb2a-sgn/.cache/hie-bios/ghc-pkg-dd5225e92f03fc6c222db1b166e462a5 ghc -v0 -- --print-libdir 2024-07-24T02:19:02.239624Z | Info | haskell-language-server version: 2.4.0.0 (GHC: 9.2.8) (PATH: /nix/store/lf2qgcgvds0kj2bcszj6wlyia2d8nqva-haskell-language-server-2.4.0.0/bin/.haskell-language-server-9.2.8-unwrapped) 2024-07-24T02:19:02.241132Z | Info | Directory: /home/mb2a-sgn/tmp/my-lib.bak 2024-07-24T02:19:02.241489Z | Info | Logging heap statistics every 60.00s ghcide setup tester in /home/mb2a-sgn/tmp/my-lib.bak. Report bugs at https://github.com/haskell/haskell-language-server/issues Step 1/4: Finding files to test in /home/mb2a-sgn/tmp/my-lib.bak Found 2 files Step 2/4: Looking for hie.yaml files that control setup Found 1 cradle () Step 3/4: Initializing the IDE 2024-07-24T02:19:02.325706Z | Debug | Initializing exports map from hiedb 2024-07-24T02:19:02.329279Z | Debug | Shake session initialized Step 4/4: Ty2024-07-24T02:19:02.329777Z | Debug | Done initializing exports map from hiedb. Size: 0 pe checking the files 2024-07-24T02:19:02.331977Z | Info | Cradle path: test/Spec.hs 2024-07-24T02:19:02.332091Z | Warning | No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for test/Spec.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. 2024-07-24T02:19:02.430194Z | Debug | Cradle: Cradle {cradleRootDir = "/home/mb2a-sgn/tmp/my-lib.bak", cradleOptsProg = CradleAction: Cabal} 2024-07-24T02:19:02.430271Z | Info | invoking build tool to determine build flags (this may take some time depending on the cache) 2024-07-24T02:19:02.430691Z | Debug | executing command: cabal exec -v0 -- ghc --print-libdir 2024-07-24T02:19:02.566124Z | Debug | executing command: cabal exec -v0 -- ghc -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath) 2024-07-24T02:19:02.753504Z | Debug | executing command: cabal --builddir=/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8 v2-repl --with-compiler /home/mb2a-sgn/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/mb2a-sgn/.cache/hie-bios/ghc-pkg-dd5225e92f03fc6c222db1b166e462a5 my-lib:test:test 2024-07-24T02:19:02.761800Z | Debug | Warning: Both /home/mb2a-sgn/.cabal and /home/mb2a-sgn/.config/cabal/config 2024-07-24T02:19:02.761884Z | Debug | exist - ignoring the former. 2024-07-24T02:19:02.761922Z | Debug | It is advisable to remove one of them. In that case, we will use the remaining 2024-07-24T02:19:02.761987Z | Debug | one by default (unless '$CABAL_DIR' is explicitly set). 2024-07-24T02:19:02.844061Z | Debug | Build profile: -w ghc-9.2.8 -O1 2024-07-24T02:19:02.844184Z | Debug | In order, the following will be built (use -v for more details): 2024-07-24T02:19:02.844252Z | Debug | - my-lib-0.1.1.0 (first run) 2024-07-24T02:19:03.009584Z | Debug | [1 of 1] Compiling Main ( /home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/setup/setup.hs, /home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/setup/Main.o ) 2024-07-24T02:19:03.074404Z | Debug | Linking /home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/setup/setup ... 2024-07-24T02:19:05.601459Z | Debug | Configuring my-lib-0.1.1.0... 2024-07-24T02:19:06.396348Z | Debug | Preprocessing library for my-lib-0.1.1.0.. 2024-07-24T02:19:06.396594Z | Debug | Building library for my-lib-0.1.1.0.. 2024-07-24T02:19:06.436605Z | Debug | [1 of 1] Compiling Lib ( src/Lib.hs, /home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/Lib.o, /home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/Lib.dyn_o ) 2024-07-24T02:19:06.974903Z | Debug | Preprocessing test suite 'test' for my-lib-0.1.1.0.. 2024-07-24T02:19:07.002648Z | Debug | executing command: cabal exec -v0 -- ghc --print-libdir 2024-07-24T02:19:07.130630Z | Debug | executing command: cabal exec -v0 -- ghc -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath) 2024-07-24T02:19:07.388621Z | Debug | executing command: cabal --builddir=/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8 v2-exec --with-compiler /home/mb2a-sgn/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/mb2a-sgn/.cache/hie-bios/ghc-pkg-dd5225e92f03fc6c222db1b166e462a5 ghc -v0 -- --print-libdir 2024-07-24T02:19:07.515064Z | Debug | Session loading result: Right (ComponentOptions {componentOptions = ["-fbuilding-cabal-package","-O0","-outputdir","/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/test/test-tmp","-odir","/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/test/test-tmp","-hidir","/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/test/test-tmp","-stubdir","/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/test/test-tmp","-i","-i/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/test/test-tmp","-itest","-i/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/test/autogen","-i/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/global-autogen","-I/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/test/autogen","-I/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/global-autogen","-I/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/test/test-tmp","-optP-include","-optP/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/test/autogen/cabal_macros.h","-hide-all-packages","-Wmissing-home-modules","-no-user-package-db","-package-db","/home/mb2a-sgn/.local/state/cabal/store/ghc-9.2.8/package.db","-package-db","/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/packagedb/ghc-9.2.8","-package-db","/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/package.conf.inplace","-package-id","base-4.16.4.0","-package-id","my-lib-0.1.1.0-inplace","-XHaskell2010","test/Spec.hs","-hide-all-packages"], componentRoot = "/home/mb2a-sgn/tmp/my-lib.bak", componentDependencies = ["my-lib.cabal","cabal.project","cabal.project.local"]},"/nix/store/71rzqz1875j0wqg27hjd1c3k1wshgfyk-ghc-9.2.8-with-packages/lib/ghc-9.2.8") 2024-07-24T02:19:07.554155Z | Info | Interface files cache directory: /home/mb2a-sgn/.cache/ghcide/main-abe72eb0b9d184a4b78236435c835c82de2f62f7 2024-07-24T02:19:07.554328Z | Info | Making new HscEnv. In-place unit ids: [main] 2024-07-24T02:19:07.564178Z | Debug | New component cache HscEnvEq: (([],Just HscEnvEq 4),fromList [("cabal.project",Nothing),("cabal.project.local",Nothing),("my-lib.cabal",Just 2024-07-24 01:20:38.272971856 UTC)]) 2024-07-24T02:19:07.565241Z | Debug | Known files updated: fromList [(TargetFile NormalizedFilePath "/home/mb2a-sgn/tmp/my-lib.bak/test/Spec.hs",fromList ["/home/mb2a-sgn/tmp/my-lib.bak/test/Spec.hs"])] 2024-07-24T02:19:07.565501Z | Debug | Finished build session AsyncCancelled 2024-07-24T02:19:07.565636Z | Debug | Restarting build session due to new component Action Queue: [User TypeCheck] Keys: [GhcSessionIO; , GetKnownTargets; ] Aborting previous build session took 0.00s 2024-07-24T02:19:07.566099Z | Debug | hlint: Getting hlint ideas for NormalizedFilePath "/home/mb2a-sgn/tmp/my-lib.bak/src/Lib.hs" 2024-07-24T02:19:07.566434Z | Debug | hlint: Getting hlint ideas for NormalizedFilePath "/home/mb2a-sgn/tmp/my-lib.bak/test/Spec.hs" 2024-07-24T02:19:07.669617Z | Info | Cradle path: src/Lib.hs 2024-07-24T02:19:07.670337Z | Warning | No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for src/Lib.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. 2024-07-24T02:19:08.111165Z | Debug | Cradle: Cradle {cradleRootDir = "/home/mb2a-sgn/tmp/my-lib.bak", cradleOptsProg = CradleAction: Cabal} 2024-07-24T02:19:08.111337Z | Info | invoking build tool to determine build flags (this may take some time depending on the cache) 2024-07-24T02:19:08.111715Z | Debug | executing command: cabal exec -v0 -- ghc --print-libdir 2024-07-24T02:19:08.113561Z | Debug | hlint: Using extensions for NormalizedFilePath "/home/mb2a-sgn/tmp/my-lib.bak/test/Spec.hs": [ MonomorphismRestriction , DeepSubsumption , RelaxedPolyRec , ForeignFunctionInterface , ImplicitPrelude , DoAndIfThenElse , EmptyDataDecls , PatternGuards , DatatypeContexts , TraditionalRecordSyntax , StarIsType , CUSKs , FieldSelectors ] 2024-07-24T02:19:08.377125Z | Debug | executing command: cabal exec -v0 -- ghc -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath) 2024-07-24T02:19:08.803937Z | Debug | executing command: cabal --builddir=/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8 v2-repl --with-compiler /home/mb2a-sgn/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/mb2a-sgn/.cache/hie-bios/ghc-pkg-dd5225e92f03fc6c222db1b166e462a5 lib:my-lib 2024-07-24T02:19:08.811796Z | Debug | Warning: Both /home/mb2a-sgn/.cabal and /home/mb2a-sgn/.config/cabal/config 2024-07-24T02:19:08.811889Z | Debug | exist - ignoring the former. 2024-07-24T02:19:08.811964Z | Debug | It is advisable to remove one of them. In that case, we will use the remaining 2024-07-24T02:19:08.812018Z | Debug | one by default (unless '$CABAL_DIR' is explicitly set). 2024-07-24T02:19:08.914855Z | Debug | Build profile: -w ghc-9.2.8 -O1 2024-07-24T02:19:08.914940Z | Debug | In order, the following will be built (use -v for more details): 2024-07-24T02:19:08.915007Z | Debug | - my-lib-0.1.1.0 (first run) 2024-07-24T02:19:09.164096Z | Debug | Preprocessing library for my-lib-0.1.1.0.. 2024-07-24T02:19:09.182360Z | Debug | executing command: cabal exec -v0 -- ghc --print-libdir 2024-07-24T02:19:09.328314Z | Debug | executing command: cabal exec -v0 -- ghc -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath) 2024-07-24T02:19:09.515158Z | Debug | executing command: cabal --builddir=/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8 v2-exec --with-compiler /home/mb2a-sgn/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/mb2a-sgn/.cache/hie-bios/ghc-pkg-dd5225e92f03fc6c222db1b166e462a5 ghc -v0 -- --print-libdir 2024-07-24T02:19:09.911174Z | Debug | Session loading result: Right (ComponentOptions {componentOptions = ["-fbuilding-cabal-package","-O0","-outputdir","/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build","-odir","/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build","-hidir","/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build","-stubdir","/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build","-i","-i/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build","-isrc","-i/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/autogen","-i/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/global-autogen","-I/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/autogen","-I/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/global-autogen","-I/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build","-optP-include","-optP/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/build/autogen/cabal_macros.h","-this-unit-id","my-lib-0.1.1.0-inplace","-hide-all-packages","-Wmissing-home-modules","-no-user-package-db","-package-db","/home/mb2a-sgn/.local/state/cabal/store/ghc-9.2.8/package.db","-package-db","/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/packagedb/ghc-9.2.8","-package-db","/home/mb2a-sgn/.cache/hie-bios/dist-my-lib-247298e905f61d04c03aea9759e9d8c8/build/x86_64-linux/ghc-9.2.8/my-lib-0.1.1.0/package.conf.inplace","-package-id","base-4.16.4.0","-XHaskell2010","Lib","-Wall","-hide-all-packages"], componentRoot = "/home/mb2a-sgn/tmp/my-lib.bak", componentDependencies = ["my-lib.cabal","cabal.project","cabal.project.local"]},"/nix/store/71rzqz1875j0wqg27hjd1c3k1wshgfyk-ghc-9.2.8-with-packages/lib/ghc-9.2.8") 2024-07-24T02:19:09.940749Z | Info | Interface files cache directory: /home/mb2a-sgn/.cache/ghcide/my-lib-0.1.1.0-inplace-f218ee120acfc56e729f2d8d77d03991f9a6e97b 2024-07-24T02:19:09.940999Z | Info | Interface files cache directory: /home/mb2a-sgn/.cache/ghcide/main-a58c0d14c10d25470fceb6d6679b09a76463064e 2024-07-24T02:19:09.941077Z | Info | Making new HscEnv. In-place unit ids: [my-lib-0.1.1.0-inplace, main] 2024-07-24T02:19:09.947035Z | Debug | New component cache HscEnvEq: (([],Just HscEnvEq 7),fromList [("cabal.project",Nothing),("cabal.project.local",Nothing),("my-lib.cabal",Just 2024-07-24 01:20:38.272971856 UTC)]) 2024-07-24T02:19:09.949026Z | Debug | New component cache HscEnvEq: (([],Just HscEnvEq 8),fromList [("cabal.project",Nothing),("cabal.project.local",Nothing),("my-lib.cabal",Just 2024-07-24 01:20:38.272971856 UTC)]) 2024-07-24T02:19:09.949939Z | Debug | Known files updated: fromList [(TargetFile NormalizedFilePath "/home/mb2a-sgn/tmp/my-lib.bak/src/Lib.hs",fromList ["/home/mb2a-sgn/tmp/my-lib.bak/src/Lib.hs"]),(TargetModule (ModuleName "Lib"),fromList ["/home/mb2a-sgn/tmp/my-lib.bak/src/Lib.hs"]),(TargetFile NormalizedFilePath "/home/mb2a-sgn/tmp/my-lib.bak/test/Spec.hs",fromList ["/home/mb2a-sgn/tmp/my-lib.bak/test/Spec.hs"])] 2024-07-24T02:19:09.950512Z | Debug | Finished build session AsyncCancelled 2024-07-24T02:19:09.951859Z | Debug | Restarting build session due to new component Action Queue: [User TypeCheck] Keys: [GhcSessionIO; , GetKnownTargets; ] Aborting previous build session took 0.00s 2024-07-24T02:19:09.952332Z | Debug | hlint: Getting hlint ideas for NormalizedFilePath "/home/mb2a-sgn/tmp/my-lib.bak/src/Lib.hs" 2024-07-24T02:19:09.955952Z | Debug | hlint: Using extensions for NormalizedFilePath "/home/mb2a-sgn/tmp/my-lib.bak/src/Lib.hs": [ MonomorphismRestriction , DeepSubsumption , RelaxedPolyRec , ForeignFunctionInterface , ImplicitPrelude , DoAndIfThenElse , EmptyDataDecls , PatternGuards , DatatypeContexts , TraditionalRecordSyntax , StarIsType , CUSKs , FieldSelectors ] 2024-07-24T02:19:09.958594Z | Info | updateFileDiagnostics published different from new diagnostics - file diagnostics: File: /home/mb2a-sgn/tmp/my-lib.bak/test/Spec.hs Hidden: no Range: 3:18-3:21 Source: not found Severity: DiagnosticSeverity_Error Message: Could not load module ‘Lib’ It is a member of the hidden package ‘libiserv-9.2.8’. Perhaps you need to add ‘libiserv’ to the build-depends in your .cabal file. 2024-07-24T02:19:09.966251Z | Debug | Finished: User TypeCheck Took: 0.01s 2024-07-24T02:19:09.970252Z | Debug | Finished: GetHie Took: 0.00s Files that2024-07-24T02:19:09.970704Z | Debug | Finished: GenerateCore Took: 0.00s failed: * /home/mb2a-sgn/tmp/my-lib.bak/test/Spec.hs Completed (1 file worked, 1 file failed) ```

The following is VS Code case.

hls.log

fendor commented 2 months ago

Hi, thank you for bug report and the detailed instructions!

HLS's support for build-type: Custom is generally speaking not great. So, I am not surprised there are a couple of sharp edges.

I can not reproduce exactly the same error, though, on the first run, I am getting:

  Failed to run ["cabal","v2-repl","/home/hugin/Downloads/my-lib/test/Spec.hs"] in directory
  "/home/hugin/Downloads/my-lib". Consult the logs for full command and error.
  Failed command: cabal
  --builddir=/home/hugin/.cache/hie-bios/dist-my-lib-52c1f96b1804b573257fc6cf0e1e0dc2 v2-repl
  --with-compiler /home/hugin/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg
  /home/hugin/.cache/hie-bios/ghc-pkg-99f55999495b863a61d4f15d989eaab4
  /home/hugin/Downloads/my-lib/test/Spec.hs
  Build profile: -w ghc-9.6.5 -O1
  In order, the following will be built (use -v for more details):
  - cabal-doctest-1.0.10 (lib) (requires build)
  - ghc-paths-0.1.0.12 (lib:ghc-paths) (requires build)
  - doctest-0.22.4 (lib) (requires download & build)
  - my-lib-0.1.1.0 (interactive) (first run)
  Downloading doctest-0.22.4
  Starting ghc-paths-0.1.0.12 (all, legacy fallback: build-type is Custom)
  Starting cabal-doctest-1.0.10 (lib)
  Downloaded doctest-0.22.4
  Building cabal-doctest-1.0.10 (lib)
  Installing cabal-doctest-1.0.10 (lib)
  Completed cabal-doctest-1.0.10 (lib)
  Building ghc-paths-0.1.0.12 (all, legacy fallback: build-type is Custom)
  Installing ghc-paths-0.1.0.12 (all, legacy fallback: build-type is Custom)
  Completed ghc-paths-0.1.0.12 (all, legacy fallback: build-type is Custom)
  Starting doctest-0.22.4 (lib)
  Building doctest-0.22.4 (lib)
  Installing doctest-0.22.4 (lib)
  Completed doctest-0.22.4 (lib)
  [1 of 2] Compiling Main (
  /home/hugin/.cache/hie-bios/dist-my-lib-52c1f96b1804b573257fc6cf0e1e0dc2/build/x86_64-linux/ghc-9.6.5/my-lib-0.1.1.0/setup/setup.hs,
  /home/hugin/.cache/hie-bios/dist-my-lib-52c1f96b1804b573257fc6cf0e1e0dc2/build/x86_64-linux/ghc-9.6.5/my-lib-0.1.1.0/setup/Main.o
  ) [Distribution.Extra.Doctest package changed]
  [2 of 2] Linking
  /home/hugin/.cache/hie-bios/dist-my-lib-52c1f96b1804b573257fc6cf0e1e0dc2/build/x86_64-linux/ghc-9.6.5/my-lib-0.1.1.0/setup/setup
  [Objects changed]
  Configuring my-lib-0.1.1.0...
  [1 of 2] Compiling Main (
  /home/hugin/.cache/hie-bios/dist-my-lib-52c1f96b1804b573257fc6cf0e1e0dc2/build/x86_64-linux/ghc-9.6.5/my-lib-0.1.1.0/setup/setup.hs,
  /home/hugin/.cache/hie-bios/dist-my-lib-52c1f96b1804b573257fc6cf0e1e0dc2/build/x86_64-linux/ghc-9.6.5/my-lib-0.1.1.0/setup/Main.o
  ) [Distribution.Extra.Doctest package changed]
  [2 of 2] Linking
  /home/hugin/.cache/hie-bios/dist-my-lib-52c1f96b1804b573257fc6cf0e1e0dc2/build/x86_64-linux/ghc-9.6.5/my-lib-0.1.1.0/setup/setup
  [Objects changed]

  Saved package config file is outdated:
  • the Cabal version changed from Cabal-3.12.1.0 to Cabal-3.10.3.0
  Re-run the 'configure' command.
  Error: [Cabal-7125]
  repl failed for my-lib-0.1.1.0.

And after I ran cabal build all --enable-testing once, it started working altogether, and I can't get it to fail again :thinking:. However, it is really slow to load the project.

Full disclosure, I am not running the nix flake as I didn't really need it.

fendor commented 2 months ago

Perhaps fixed on a more recent HLS version? Could you try to reproduce on a more recent GHC version that has proper multi home unit support and more recent HLS version?

mb2a-sgn commented 2 months ago

Thank you for your cooperation.

Indeed, the HLS version 2.4.0 was outdated. After updating GHC to 9.4.8 and HLS to 2.9.00, the problem is not reproduced in my environment. my-lib.tar.gz

The problem seems to be probabilistic so it's not easy, but I think we can close this issue until the problem occurs again.

fendor commented 2 months ago

Thanks for checking!

Ok, then let's close this and feel free to reopen or open a new issue if you run into any problems :)