-
Notifications
You must be signed in to change notification settings - Fork 208
"Could not find module" error on local imports #1333
Comments
I have pretty the same issue, but i use ghc with plain Makefile. Steps to reproduce: For excample, i have project like this.
If I open Main.hs, hie doesn't show any errors. But if i open Foo.hs, which imports Bar and A, hie sends "Could not find module ‘Dir.Bar’" and "Could not find module ‘A’" errors. If then i open A.hs and Bar.hs in my editor (probably, enough to send "textDocument/didOpen" action to hie, because I have this error both on neovim and vscode), and then switch back to Foo.hs all errors disappear. |
The same issue with latest vim and hie-8.6.5 on macOS |
@BananchickPasha We are not supporting plain ghc with Makefile out of the box. @tchoutri the issue is not similar to #1069 as this is related to nix. It is possible that your issue has been fixed on latest master. If not, please provide more steps to reproduce your set-up and project. @tim2CF Please provide more information, both prior posts have different problems. |
@fendor: I'm a first-time user of I used to experience similar issues with Intero and stack unless I'd rebuild the project's new dependencies. This doesn't work here. EnvironmentI'm experiencing the same issue, as described by others, on Linux using
{
"languageserver": {
"haskell": {
"command": "stack",
"args": ["exec", "ghcide", "--", "--lsp"],
"rootPatterns": [
".stack.yaml",
".hie-bios",
"BUILD.bazel",
"cabal.config",
"stack.yaml",
"package.yaml"
],
"filetypes": [
"hs",
"lhs",
"haskell"
],
"initializationOptions": {},
"settings": {
"languageServerHaskell": {
"hlintOn": true,
"languageServerHaskell.useHieWrapper": false,
"useHieWrapper": false,
"liquidOn": false,
"diagnosticsDebounceDuration": 10,
"completionSnippetsOn": true,
"formatOnImportOn": true,
"formattingProvider": "brittany"
}
}
}
} A trivial pathological counterexampleThe following trivial project exhibits the mentioned behavior of
What I can tell so far with certainty is that the issue pertains exclusively to the packages with specified hashes. No import from -- excerpt from below
, "-package-id=base-4.12.0.0"
, "-package-id=scotty-0.11.5-5bX7ciYVp5pLFVLwTO5PeP"
-- omitted And as Pasha reports above, project-internal libraries exhibit the same issue. To be more precise, there is no problem with the packages in ~/.stack/programs/x86_64-linux/ghc-8.6.5/lib/ghc-8.6.5/ So I suppose it should make sense to regress on other paths in EDIT [2019-12-28 10:05, 10:35 UTC]Indeed, another fresh tiny project of mine, using ~/.stack/programs/x86_64-linux/ghc-8.4.4/lib/ghc-8.4.4/ and provide good imports in the sense of the IDE (otherwise they compile properly). However, the packages dependencies:
- base >= 4.7 && < 5
- transformers
- mtl
# - zip-archive
- zip
- filepath
- directory
- path
- path-io In addition, in this project, I've built both the packages
(the position of error in nvim emphasized by square brackets), in the status bar I get the error
When I switch to
$ stack build hdevtools
$ stack exec hdevtools -- check app/Main.hs
<No output>
$ stack build hlint
$ stack exec hlint app/Main.hs
No hints
$ stack build hie-bios
$ stack exec which hie-bios
~/.local/bin/hie-bios # (I installed previously to ~/.local/bin/hie-bios from lts-14.18, should be project-local otherwise)
$ stack exec hie-bios check app/Main.hs
app/Main.hs:5:1:Warning: The import of ‘Data.Maybe’ is redundant
except perhaps to import instances from ‘Data.Maybe’
To import instances alone, use: import Data.Maybe() this is precisely the redundancy hint that I see on the first letter of the import expression I don't know which backend provides the import errors to EDIT_END<<< In the project sandbox:
Options: ["-i"
, "-odir=/home/qenep/projects/haskell/webapps/2019-12-27/test-scotty/.stack-work/odir"
, "-hidir=/home/qenep/projects/haskell/webapps/2019-12-27/test-scotty/.stack-work/odir"
, "-hide-all-packages"
, "-i/home/qenep/projects/haskell/webapps/2019-12-27/test-scotty/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build"
, "-i/home/qenep/projects/haskell/webapps/2019-12-27/test-scotty/src"
, "-i/home/qenep/projects/haskell/webapps/2019-12-27/test-scotty/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/autogen"
, "-i/home/qenep/projects/haskell/webapps/2019-12-27/test-scotty/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/global-autogen"
, "-stubdir=/home/qenep/projects/haskell/webapps/2019-12-27/test-scotty/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build"
, "-package-id=base-4.12.0.0"
, "-package-id=scotty-0.11.5-5bX7ciYVp5pLFVLwTO5PeP"
, "-i/home/qenep/projects/haskell/webapps/2019-12-27/test-scotty/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/test-scotty-exe"
, "-i/home/qenep/projects/haskell/webapps/2019-12-27/test-scotty/app"
, "-i/home/qenep/projects/haskell/webapps/2019-12-27/test-scotty/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/test-scotty-exe/autogen"
, "-i/home/qenep/projects/haskell/webapps/2019-12-27/test-scotty/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/test-scotty-exe/test-scotty-exe-tmp"
, "-rtsopts"
, "-with-rtsopts=-N"
, "-optP-include"
, "-optP/home/qenep/projects/haskell/webapps/2019-12-27/test-scotty/.stack-work/ghci/79fbbfcf/cabal_macros.h"
, "-ghci-script=/tmp/haskell-stack-ghci/44d98b12/ghci-script"
, "-package-db"
, "/home/qenep/projects/haskell/webapps/2019-12-27/test-scotty/.stack-work/install/x86_64-linux/05bc0afa4f6c81add4ff2cc3889c9f5c5734456008cdbaea9b84feb4e19d6ade/8.6.5/pkgdb"
, "-package-db"
, "/home/qenep/.stack/snapshots/x86_64-linux/05bc0afa4f6c81add4ff2cc3889c9f5c5734456008cdbaea9b84feb4e19d6ade/8.6.5/pkgdb"
, "-package-db"
, "/home/qenep/.stack/programs/x86_64-linux/ghc-8.6.5/lib/ghc-8.6.5/package.conf.d"]
Dependencies: ["test-scotty.cabal","package.yaml","stack.yaml"] RemarksThe issue is common to
SuggestionIt would be great to know whether there is a way to instruct In addition, slightly less related, I've been experiencing an issue with erroneous interface files in |
@qenep Thank you for this extremely detailed bug report, it is very helpful! It will take some time to analyse everything you reported, so I will just start with explaining I will address the other parts of your bug-report once I have something useful to say ;D |
@fendor: Thanks for your quick reply. I will do as you suggest and report back. Now that you mention You say that
I haven't had enough time yet to work with either, but have followed the discussions on Reddit and other public forums as well as blogs. My impression is that some participants expressed the sentiment that essentially In my fairly limited experience, having changed "languageServerHaskell.useHieWrapper": true,
"useHieWrapper": true has indeed improved the speed a bit, depending on the project size, and reduced memory consumption, andectodically by a half. I've specified these details here because I'm not yet confident that I correctly specified the desired configuration. I've controlled the system processes and observed that indeed There is still a bit of ambiguity also in what As you can see above, I followed suite with with that blog post, and moved the configuration of the language server from Right now, to verify what I'm writing, with the language server configuration as stated in my first comment above ( ~/.stack/compiler-tools/x86_64-linux/ghc-8.6.5/bin/ghcide --lsp slightly increase CPU load, and the hie --lsp process (global, i.e., from I hope this adds a couple of brush strokes to the picture. But the obvious thing to do now is proceed as you suggested and build first The comment has become longer than intended. But I'd also like to express my gratitude for the privilege to use |
Ok, now I've built and installed it, $ git pull --recurse-submodules
$ stack ./install.hs hie-8.6.5
$ cd ~/projects/haskell/webapps/2019-12-27/test-scotty
$ nvim app/Main.hs Just for completeness, I've tried what follows before and after installing the target ObservationsThe old error message remains,
A new error messageNow I get the additional error highlight on the first character in "
This message does not populate the I'm not sure why it appears. I don't think that it is appropriate, since I didn't touch the project. But once rebuild, and it did rebuild actually, this error message disappeared. So I suppose something in the relevant stack snapshot must have changed. All I did on this machine was to rebuild and install EDIT [2019-12-28 19:50 UTC]: I've run $ killall hie
$ killall ghcide
$ killall hdevtools and opened the same file. First, only the red blocks appeared and only three Then I quit nvim and repeated the termination of processes as it appeared that some were respawned by other instances of But when I quit and opened nvim again, it all looked as before that: red block for the first char, PRAGMA as before, and again that message about "cannot satisfy..." So next, as I'm writing this, I terminate $ killall -9 -v node hie ghcide ghc
<... terminated successfully ...>
$ nvim app/Main.hs And I see the picture prior to this edit, as outlined in this entire comment: As you see the error message appears (but not in EDIT_END<<< Another additional error messageThe errors on "
Interestingly, only this message appears in BlockingIn addition, as a result of adding the expression But it returns once I remove the nonsense expression Unfortunately, while blocked, LSP providers stop to work. So, for example, the normal-mode map A closely related issueA related issue that has just come up in this context: the following is obviously wrong but that Another closely related issueMoreover, these two blocks with the red background disappear, whenever I suspend nvim (Ctrl-z) and then resume ( |
The error message:
Is likely to be caused by #1499. Later in the conversation, the work-around adding a cradle:
stack: also works. You are suggesting multiple different features here, it would be useful to have them split into multiple issues. Yes, parsing errors (which this "abc" is) happen early on the GHC phase, and it only reports those. So for an initial load, nothing else is possible. GHC does not give us more than that. |
Ok, thanks for your reply, I'll investigate this further and split the issues as soon as I can, likely in a few days from now, and will report back. As for the GHC limitation, I will just hope this would improve over time. I think as soon as Have a Happy New Year! |
I'm having a similar issue with Emacs and a multi-package Reflex project, |
@thalesmg Please link logs and output from |
@fendor I do not have the Buffer
|
I had a mental typo, I meant EDIT:
I do not quite understand what you mean by that. Since you use a MORE EDIT: |
|
No, that is not supported. You would have to use |
I see. I'll have to research more if there is a way to use the cabal file that Nix generates automatically during the build.
Thanks for your help! 🍺 |
Expected Behaviour
Not showing any error when importing a local module in another module
Current Behaviour
This error message in Neovim's
:messages
bufferAdditional Notes
This issue is similar to #1069, but I use stack + hpack
How could I debug the root cause of those issues?
The text was updated successfully, but these errors were encountered: