-
-
Notifications
You must be signed in to change notification settings - Fork 389
Can't find project modules in test/Spec.hs
until I restart VSCode
#1909
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
Comments
test/Spec.hs
test/Spec.hs
until I restart VSCode
Hi, thanks for the bug report, is it possible that the quad.cabal file generated from package.yaml does not include the new module when hls did not find it? |
Hello. So I tested that out. I created a new module called It seems like it was able to detect it just fine, I think. Stack seems to recognize it as well because both the Just in case, here's the entire
|
Hey @hsek could you try doing the following things outside of vscode?
I think I'm having the same issue (also using stack, but via vim), where until I manually recompile my lib, hls refuses to acknowledge its existence. Additionally I would be grateful if you could also try
When I do the same, instead of getting the error reported to me in the test suite, I get a "cannot find package blabla..." error, referring to the library again. The purpose of this is to hopefully see if there's more of a link between the first (your) error case, and #735 |
I followed what @googleson78 asked. Installed hls in { pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/60cce7e5e1fdf62421ef6d4184ee399b46209366.tar.gz") {} }:
with pkgs;
let
inherit (lib) optional optionals;
in
mkShell {
buildInputs = with haskellPackages; [
stack
ghc
zlib
record-dot-preprocessor
haskell-language-server
]
++ optional stdenv.isLinux libnotify
++ optional stdenv.isLinux inotify-tools;
} From within File: /home/sekun/Projects/quad-ci/src/Docker.hs
Hidden: no
Range: 40:18-40:25
Source: hlint
Severity: DsInfo
Message: Redundant bracketFound:(Image)Why not:Image
File: /home/sekun/Projects/quad-ci/src/Docker.hs
Hidden: no
Range: 40:49-40:73
Source: hlint
Severity: DsInfo
Message: Redundant bracketFound:(CreateContainerOptions)Why not:CreateContainerOptions
2021-06-11 22:04:34.933965077 [ThreadId 285] INFO hls: File: /home/sekun/Projects/quad-ci/test/Spec.hs
Hidden: no
Range: 7:18-7:24
Source: not found
Severity: DsError
Message:
Could not find module ‘Sample’
It is not a module in the current program, or in any known package.
2021-06-11 22:04:35.210355872 [ThreadId 477] INFO hls: File: /home/sekun/Projects/quad-ci/src/Docker.hs
Hidden: no
Range: 8:1-10:4
Source: hlint
Severity: DsInfo
Message:
Use newtype instead of data
Found:
data CreateContainerOptions
= CreateContainerOptions {image :: Image}
Why not:
newtype CreateContainerOptions
= CreateContainerOptions {image :: Image}
decreases laziness
File: /home/sekun/Projects/quad-ci/src/Docker.hs
Hidden: no
Range: 40:18-40:25
Source: hlint
Severity: DsInfo
Message: Redundant bracketFound:(Image)Why not:Image
File: /home/sekun/Projects/quad-ci/src/Docker.hs
Hidden: no
Range: 40:49-40:73
Source: hlint
Severity: DsInfo
Message: Redundant bracketFound:(CreateContainerOptions)Why not:CreateContainerOptions
File: /home/sekun/Projects/quad-ci/src/Docker.hs
Hidden: no
Range: 32:3-32:14
Source: typecheck
Severity: DsWarning
Message:
In the use of ‘traceShowIO’
(imported from RIO, but defined in rio-0.1.20.0:RIO.Prelude.Trace):
"Trace statement left in code"
2021-06-11 22:04:35.262396091 [ThreadId 487] INFO hls: finish: User TypeCheck (took 0.41s)
2021-06-11 22:04:35.275190287 [ThreadId 495] INFO hls: finish: GetHie (took 0.01s)
Files that failed:
* /home/sekun/Projects/quad-ci/test/Spec.hs
Completed (5 files worked, 1 file failed)
2021-06-11 22:04:35.299195348 [ThreadId 499] INFO hls: finish: GenerateCore (took 0.02s)
Made a change in
Then I ran [nix-shell:~/Projects/quad-ci]$ stack test
quad-0.0.0: unregistering (components added: exe:quad)
quad> configure (lib + exe + test)
Configuring quad-0.0.0...
quad> build (lib + exe + test)
Preprocessing library for quad-0.0.0..
Building library for quad-0.0.0..
[1 of 5] Compiling Paths_quad
[2 of 5] Compiling Sample
[3 of 5] Compiling Socket
[4 of 5] Compiling Docker
/home/sekun/Projects/quad-ci/src/Docker.hs:32:3: warning: [-Wdeprecations]
In the use of ‘traceShowIO’
(imported from RIO, but defined in rio-0.1.20.0:RIO.Prelude.Trace):
"Trace statement left in code"
|
32 | traceShowIO res
| ^^^^^^^^^^^
[5 of 5] Compiling Core [Docker changed]
Preprocessing executable 'quad' for quad-0.0.0..
Building executable 'quad' for quad-0.0.0..
[2 of 2] Compiling Paths_quad
Linking .stack-work/dist/x86_64-linux-nix/Cabal-3.2.1.0/build/quad/quad ...
Preprocessing test suite 'quad-test' for quad-0.0.0..
Building test suite 'quad-test' for quad-0.0.0..
[2 of 2] Compiling Main
/home/sekun/Projects/quad-ci/test/Spec.hs:23:17: error:
Not in scope: type constructor or class ‘Pipelin’
Perhaps you meant ‘Pipeline’ (imported from Core)
|
23 | testPipeline :: Pipelin
| ^^^^^^^
Progress 1/2
-- While building package quad-0.0.0 (scroll up to its section to see the error) using:
/home/sekun/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.4 --builddir=.stack-work/dist/x86_64-linux-nix/Cabal-3.2.1.0 build lib:quad exe:quad test:quad-test --ghc-options " -fdiagnostics-color=always"
Process exited with code: ExitFailure 1 Let me know if I did something incorrectly. |
I made the repo public in case someone wants to reproduce the issue. I isolated it in a nix environment, so hopefully that would make things easier. https://github.com/hsek/quad-ci/tree/fa44eb79b6b6085fc7326f88973e5047936d7efd |
I also noticed that I got the same error message as #735 after performing the above, and then going back to VSCode. Had to run |
I think it the root issue is the same as #366, so the resolution and the possible workaround will be the same too. |
Your environment
Output of
haskell-language-server --probe-tools
orhaskell-language-server-wrapper --probe-tools
:I don't know how to run this in VSCode.
Which OS do you use:
NixOS 21.05
Which lsp-client do you use:
VSCode's official hls plugin
Describe your project (alternative: link to the project):
I'm using
stack
. Following the simple haskell handbook project.Contents of
hie.yaml
:N/A
Steps to reproduce
The project is structured this way:
Then when trying to import the
Docker
module, HLS complains about how it can't find it.What's weird is that previously, it couldn't find the
Core
module. Not sure what changed, and weird that this time it doesn't know what theDocker
module is even if it's just in the same folder asCore
.Expected behaviour
It's supposed to import the project's modules just fine in the test.
Actual behaviour
It can't find the modules properly.
Include debug information
So I tried following the instructions, and restarted VSCode. Now it seems to detect it normally. But does it mean I have to restart VSCode every time I add a new module? Weird that when I tried restarting the LSP server, it still had the same issue so I had to restart the entire VSCode for it to work.
The text was updated successfully, but these errors were encountered: