Open aveltras opened 3 years ago
Hi!
Is Lib2 listed as a module target? (Not sure about hie-bios but HLS definitely does not just find Modules in the include directories.)
What does the output of hie-bios debug backend/pacakge-a
say?
I'm not sure what you mean by "module target".
hie.yaml
cradle:
multi:
- path: ./.
config: { cradle: { none: } }
- path: "./backend"
config:
cradle:
bios:
program: ".hie-bios"
.hie-bios
#!/usr/bin/env bash
set -euo pipefail
bazel build :hie-bios --output_groups=hie_bios --experimental_show_artifacts
cat bazel-bin/hie-bios@hie-bios >"$HIE_BIOS_OUTPUT"
# Make warnings non-fatal
echo -Wwarn >>"$HIE_BIOS_OUTPUT"
cat bazel-bin/hie-bios@hie-bios
-package-id
base-4.14.1.0
-package-id
base-4.14.1.0
-pgma
bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python
-pgmc
bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python
-pgml
bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python
-pgmP
bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python -E -undef -traditional
-optc-fno-stack-protector
-ibackend/package-b/
-ibazel-out/k8-fastbuild/bin/backend/package-b/
-ibackend/package-a/
-ibazel-out/k8-fastbuild/bin/backend/package-a/
backend/package-b/src/Lib2.hs
backend/package-a/src/Main.hs
hie-bios debug backend/package-a
Root directory: /home/romain/Code/skeleton
Component directory: /home/romain/Code/skeleton
GHC options: -package-id base-4.14.1.0 -package-id base-4.14.1.0 -pgma bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python -pgmc bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python -pgml bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python -pgmP "bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python -E -undef -traditional" -optc-fno-stack-protector -ibackend/package-b/ -ibazel-out/k8-fastbuild/bin/backend/package-b/ -ibackend/package-a/ -ibazel-out/k8-fastbuild/bin/backend/package-a/ backend/package-b/src/Lib2.hs backend/package-a/src/Main.hs -Wwarn
GHC library directory: CradleSuccess "/nix/store/dw33h578wv2rqcxl0yhpcrfs33p0rl2r-ghc-8.10.4-with-packages/lib/ghc-8.10.4"
GHC version: CradleSuccess "8.10.4"
Config Location: /home/romain/Code/skeleton/hie.yaml
Cradle: Cradle {cradleRootDir = "/home/romain/Code/skeleton", cradleOptsProg = CradleAction: Multi}
Dependencies:
hie-bios check backend/package-a/src/Main.hs
backend/package-a/src/Main.hs:3:1:Could not find module ‘Lib2’
Perhaps you meant Lib (from libiserv-8.10.4)
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
hie-bios debug backend/package-b
Root directory: /home/romain/Code/skeleton
Component directory: /home/romain/Code/skeleton
GHC options: -package-id base-4.14.1.0 -package-id base-4.14.1.0 -pgma bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python -pgmc bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python -pgml bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python -pgmP "bazel-out/host/bin/external/rules_haskell/haskell/cc_wrapper-python -E -undef -traditional" -optc-fno-stack-protector -ibackend/package-b/ -ibazel-out/k8-fastbuild/bin/backend/package-b/ -ibackend/package-a/ -ibazel-out/k8-fastbuild/bin/backend/package-a/ backend/package-b/src/Lib2.hs backend/package-a/src/Main.hs -Wwarn
GHC library directory: CradleSuccess "/nix/store/dw33h578wv2rqcxl0yhpcrfs33p0rl2r-ghc-8.10.4-with-packages/lib/ghc-8.10.4"
GHC version: CradleSuccess "8.10.4"
Config Location: /home/romain/Code/skeleton/hie.yaml
Cradle: Cradle {cradleRootDir = "/home/romain/Code/skeleton", cradleOptsProg = CradleAction: Multi}
Dependencies:
hie-bios check backend/package-b/src/Lib2.hs
doesn't output anything
Just checking, your build process, e.g. bazel build
works as expected?
I checked with just base flags, e.g.
> ghc -package-id base-4.14.1.0 -package-id base-4.14.1.0 -optc-fno-stack-protector -ibackend/package-b/ -ibackend/package-a/ backend/package-b/src/Lib2.hs backend/package-a/src/Main.hs -Wwarn
which worked fine.
Deleting all these -pgma
, -pgml
and -ibazel-out
worked fine for me.
Going to try reproduce later with bazel.
bazel build //backend/package-a:exe
works fine
bazel build //backend/package-b:lib
works fine
bazel run //:hie-bios
correctly enters ghci with Main and Lib2 loaded
Replacing the .hie-bios
content with:
#!/usr/bin/env bash
set -euo pipefail
# bazel build :hie-bios --output_groups=hie_bios --experimental_show_artifacts
# cat bazel-bin/hie-bios@hie-bios >"$HIE_BIOS_OUTPUT"
cat debug.txt >"$HIE_BIOS_OUTPUT"
# Make warnings non-fatal
echo -Wwarn >>"$HIE_BIOS_OUTPUT"
with debug.txt
being
-package-id
base-4.14.1.0
-optc-fno-stack-protector
-ibackend/package-b/
-ibackend/package-a/
backend/package-b/src/Lib2.hs
backend/package-a/src/Main.hs
hie-bios check backend/package-a/src/Main.hs
still fails with:
backend/package-a/src/Main.hs:3:1:Could not find module ‘Lib2’
Perhaps you meant Lib (from libiserv-8.10.4)
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
Is hie-bios
using the .hie-bios
script or is it unrelated here ?
hie-bios is using .hie-bios
script, but its session loading logic could be flawed... however, I assume HLS still doesn't work with that .hie-bios
script?
Running haskell-language-server --debug backend
with the debug.txt
version:
haskell-language-server version: 1.2.0.0 (GHC: 8.10.4) (PATH: /nix/store/5vkn6fdmg7xnrfvxsknj70svjx4bbnyq-haskell-language-server-1.2.0.0/bin/haskell-language-server)
ghcide setup tester in /home/romain/Code/skeleton.
Report bugs at https://github.com/haskell/haskell-language-server/issues
Step 1/4: Finding files to test in /home/romain/Code/skeleton
Found 2 files
Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
(/home/romain/Code/skeleton/hie.yaml)
Step 3/4: Initializing the IDE
Step 4/4: Type checking the files
2021-07-14 12:30:47.2374253 [ThreadId 58] DEBUG hls: hlint:getIdeas:file:NormalizedFilePath "/home/romain/Code/skeleton/backend/package-a/src/Main.hs"
2021-07-14 12:30:47.2374232 [ThreadId 57] DEBUG hls: hlint:getIdeas:file:NormalizedFilePath "/home/romain/Code/skeleton/backend/package-b/src/Lib2.hs"
2021-07-14 12:30:47.2377998 [ThreadId 65] INFO hls: Consulting the cradle for "backend/package-a/src/Main.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/romain/Code/skeleton", cradleOptsProg = CradleAction: Multi}
2021-07-14 12:30:47.2839177 [ThreadId 65] DEBUG hls: Session loading result: Right (ComponentOptions {componentOptions = ["-package-id","base-4.14.1.0","-optc-fno-stack-protector","-ibackend/package-b/","-ibackend/package-a/","backend/package-b/src/Lib2.hs","backend/package-a/src/Main.hs","-Wwarn"], componentRoot = "/home/romain/Code/skeleton", componentDependencies = []},"/nix/store/dw33h578wv2rqcxl0yhpcrfs33p0rl2r-ghc-8.10.4-with-packages/lib/ghc-8.10.4")
2021-07-14 12:30:47.3251764 [ThreadId 65] INFO hls: Using interface files cache dir: /home/romain/.cache/ghcide/main-b50e6dc02bf5c2d0a6f341cde882f1c2a3f576fc
2021-07-14 12:30:47.3253269 [ThreadId 65] INFO hls: Making new HscEnv[main]
2021-07-14 12:30:47.3332828 [ThreadId 65] DEBUG hls: New Component Cache HscEnvEq: (([],Just HscEnvEq 5),fromList [("/home/romain/Code/skeleton/hie.yaml",Just 2021-07-14 08:53:54.47 UTC)])
2021-07-14 12:30:47.3336951 [ThreadId 65] DEBUG hls: Known files updated: fromList [(TargetFile NormalizedFilePath "/home/romain/Code/skeleton/backend/package-b/src/Lib2.hs",fromList ["/home/romain/Code/skeleton/backend/package-b/src/Lib2.hs"]),(TargetFile NormalizedFilePath "/home/romain/Code/skeleton/backend/package-a/src/Main.hs",fromList ["/home/romain/Code/skeleton/backend/package-a/src/Main.hs"])]
2021-07-14 12:30:47.334249 [ThreadId 25] DEBUG hls: Finishing build session(exception: AsyncCancelled)
2021-07-14 12:30:47.3343353 [ThreadId 65] DEBUG hls: Restarting build session for keys [GhcSessionIO; ] (aborting the previous one took 0.00s)
2021-07-14 12:30:47.3355484 [ThreadId 124] DEBUG hls: hlint:getIdeas:file:NormalizedFilePath "/home/romain/Code/skeleton/backend/package-a/src/Main.hs"
2021-07-14 12:30:47.335551 [ThreadId 123] DEBUG hls: hlint:getIdeas:file:NormalizedFilePath "/home/romain/Code/skeleton/backend/package-b/src/Lib2.hs"
2021-07-14 12:30:47.3446089 [ThreadId 194] INFO hls: File: /home/romain/Code/skeleton/backend/package-a/src/Main.hs
Hidden: no
Range: 3:8-3:12
Source: not found
Severity: DsError
Message: Could not find module ‘Lib2’Perhaps you meant Lib (from libiserv-8.10.4)
2021-07-14 12:30:47.3554499 [ThreadId 217] INFO hls: finish: User TypeCheck (took 0.02s)
2021-07-14 12:30:47.3569664 [ThreadId 228] INFO hls: finish: GetHie (took 0.00s)
Files that failed:
* /home/romain/Code/skeleton/backend/package-a/src/Main.hs
Completed (1 file worked, 1 file failed)
2021-07-14 12:30:47.3571385 [ThreadId 229] INFO hls: finish: GenerateCore (took 0.00s)
I did not forget this issue, I can reproduce it locally, however, I currently don't know what causes the issue :(
Just mentioning @aherrmann in case he could shed some light on this. That would be a follow-up from https://github.com/tweag/rules_haskell/issues/1560
I'm currently trying to get haskell-language-server to work with a bazel built repo. Failing project here: https://github.com/aveltras/haskell-bazel-nix/tree/4228d1ecf1ad362d04f11ee058d24f25aba61552 The debug outputs are at the bottom of the readme.
I have two bazel targets backend/package-a (executable) and backend/package-b (library) which I'm trying to setup haskell-language-server with. Running
hie-bios check
on the executable fails which a Could not find module ‘Lib2 even if the directory containing Lib2 is included with -ibackend/package-b/ in the .hie-bios script.The problem seems to be the same as #275 but I could not find a fix by reading the comments.