haskell / haskell-ide-engine

The engine for haskell ide-integration. Not an IDE
BSD 3-Clause "New" or "Revised" License
2.38k stars 211 forks source link

Could not find module 'Prelude': hie with coc.nvim #1647

Closed OxSon closed 4 years ago

OxSon commented 4 years ago

Hello all,

I tried searching the issues to find something similar and was unsuccessful (#1359 is not the same issue).

I'm trying to use hie with coc.nvim on arch. I get a popup that says:

[bios] [E] Could not find module 'Prelude'
There are files missing in the 'base-4.12.0.0`package,
try running 'ghc-pkg check'.

The output of ghc-pkg check is quite long, let me know if that output is needed in order to help.

OxSon commented 4 years ago

I also get a similar error on any import statement. E.g. import Data.List gives me an identical error as above, but with Could not find module 'Prelude' replaced by Could not find module 'Data.List

Avi-D-coder commented 4 years ago

Are you using stack or cabal?

OxSon commented 4 years ago

Neither, in this particular case. Is that the issue? Apologies if I sound like an idiot. I'm new to the haskell ecosystem. I just have a directory that contains some *.hs files. I am working through the Haskell Wikibook.

OxSon commented 4 years ago

I installed stack and made a dummy project to test. It works fine there. Thanks for the help and sorry for the noise.

Avi-D-coder commented 4 years ago

No worries. Let us know if you have any other questions.

oblitum commented 4 years ago

Same behavior here, currently using haskell-language-server. Is there any way to have it working without involving cabal or stack, for simple single file coding, as alternative to ghci? ghci works fine on my system so I dunno why the server can't find Prelude of the system ghc.

oblitum commented 4 years ago

Figured it out. Just had to install the ghc-static package, as ArchLinux primarily have a -dynamic setup, which the server can't pick by default and seems there's no way to set a -dynamic flag in LSP configuration alone.

oblitum commented 4 years ago

Reference: https://bugs.archlinux.org/task/65661

Avi-D-coder commented 4 years ago

@oblitum I would advise using ghcup to manage GHC and cabal installs. I'm also on arch; arch's Haskell packaging is a monstrosity, -static suffix pkgs are better, but still have issues.

If you use stack set system-ghc: true in ~/.stack/global-project/stack.yaml And just use ghcup, this will work better with cabal. Even if you use stack, most opensource packages will be using cabal. I would also advise using cabal, it's better than stack these days (from a IDE dev and user perspective).

If your not into ghcup, I hear nix also works well.

oblitum commented 4 years ago

@Avi-D-coder thanks for tips! I'm doing all that. I'm going to pick Haskell for a look again, left it before because tooling is nightmarish. I always found stack and cabal duplicating work, and I'm a simple man, so, I'm going to try sticking to cabal only, since it looks like to have improved substantially, if ghcup becomes as simple as rustup, then I'm all for it and dumping pacman's ghc in my endeavor.