Skip to content
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

cabal cannot find Main #304

Closed
HE7086 opened this issue Aug 9, 2020 · 2 comments
Closed

cabal cannot find Main #304

HE7086 opened this issue Aug 9, 2020 · 2 comments

Comments

@HE7086
Copy link

HE7086 commented Aug 9, 2020

I am getting this error on Main.hs, while other files worked fine
cabal can build the executable and it runs fine.
this only occurs with hls but not hie (previously, like several months ago)

Screenshot_20200810_003143

a toy project can be found here
(note that -dynamic flag maybe not required on other distributions)

env:
arch linux
neovim with coc
ghc 8.10.1, cabal 3.2.0.0, all dynamically linked
hls 0.2.2 from AUR

:CocInfo output:

## versions

vim version: NVIM v0.4.4
node version: v14.7.0
coc.nvim version: 0.0.78-bdd9a9e140
coc.nvim directory: /home/he/.config/nvim/plugged/coc.nvim
term: xterm-256color
platform: linux

## Output channel: languageserver.haskell

Module "/home/he/code/Fourier/src/a" is loaded by Cradle: 
Cradle {cradleRootDir = "/home/he/code/Fourier", cradleOptsProg = CradleAction: Cabal}
Run entered for haskell-language-server-wrapper
(haskell-language-server-wrapper) Version 0.2.2.0, 
Git revision e44f618c11b7978264a94beeee00d1f014867f6d (dirty) x86_64 ghc-8.10.1
Current directory: /home/he/code/Fourier/src
Operating system: linux
Arguments: ["--lsp"]
Cradle directory: /home/he/code/Fourier
Cradle type: Cabal
Consulting the cradle to get project GHC version...
Project GHC version: 8.10.1
haskell-language-server exe candidates: 
["haskell-language-server-8.10.1","haskell-language-server-8.10","haskell-language-server"]
Launching haskell-language-server exe at:/usr/bin/haskell-language-server-8.10.1
haskell-language-server version: 0.2.2.0 (GHC: 8.10.1) 
(PATH: /usr/bin/haskell-language-server-8.10.1) 
(GIT hash: e44f618c11b7978264a94beeee00d1f014867f6d)
Starting (haskell-language-server)LSP server... 
with arguments: LspArguments 
{
    argLSP = True, 
    argsCwd = Nothing, 
    argFiles = [], 
    argsShakeProfiling = Nothing, 
    argsTesting = False, 
    argsExamplePlugin = False, 
    argsDebugOn = False, 
    argsLogFile = Nothing, 
    argsThreads = 0, 
    argsProjectGhcVersion = False
}
with plugins: 
[
    PluginId "eval",
    PluginId "floskell",
    PluginId "ghcide",
    PluginId "ormolu",
    PluginId "pragmas",
    PluginId "stylish-haskell"
]
  in directory: /home/he/code/Fourier
If you are seeing this in a terminal, 
you probably should have run ghcide WITHOUT the --lsp option!
 
Started LSP server in 0.00s
2020-08-10 00:23:33.229718237 [ThreadId 17] - Opened text document: file:///home/he/code/Fourier/src/Main.hs
Data.HashMap.Base.(!): key not found
CallStack (from HasCallStack):
  error, called at ./Data/HashMap/Base.hs:733:16 in unordered-containers-0.2.11.0-0b1b8f67eff94409f2a679203f1f70f269da36a64c96a4b431ee329c4593e137:Data.HashMap.Base!, 
  called at src/Development/IDE/Import/DependencyInformation.hs:107:40 in ghcide-0.2.0-inplace:Development.IDE.Import.DependencyInformation
2020-08-10 00:23:33.230548342 [ThreadId 51] - Consulting the cradle for "/home/he/code/Fourier/src/Main.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/he/code/Fourier", cradleOptsProg = CradleAction: Cabal}
> cabal: Unknown target '/home/he/code/Fourier/src/Main.hs'.
> The package Fourier has no file target 'src/Main.hs'.
> 
> 
2020-08-10 00:23:35.234646606 [ThreadId 64] - Plugin.makeCodeLens (ideLogger)
2020-08-10 00:23:35.235621515 [ThreadId 35] - finish: codeLens (took 0.00s)

## Output channel: highlight

[Info  - 12:23:33 AM] Highlight server running in node v14.7.0
@fendor
Copy link
Collaborator

fendor commented Aug 10, 2020

Hi! Thank you for the bug report! To me, it looks like this cabal bug: haskell/cabal#6622
Issue in HIE: haskell/haskell-ide-engine#1727 and in hie-bios: haskell/hie-bios#164

TLDR; the bug is cabal repl src/Main.hs fails, although it should not. It should be fixed in cabal 3.4 (sadly not backported to 3.2) and a work-around is to write your own hie.yaml file. Reference: https://github.com/mpickering/hie-bios/#cabal
If there are more questions regarding writing your own hie.yaml, feel free to ask or even open an issue at hie-bios. (We are trying to improve the docs)

EDIT: in the readme the section https://github.com/haskell/haskell-language-server#project-configuration might be helpful as well.

@HE7086
Copy link
Author

HE7086 commented Aug 10, 2020

thanks, hie.yaml works

this workaround seems like a compile database,
wonder if it could be generated automatically, like CMAKE_EXPORT_COMPILE_COMMANDS for cmake, tho

@HE7086 HE7086 closed this as completed Aug 10, 2020
pepeiborra pushed a commit that referenced this issue Dec 27, 2020
I accidentally broke this on Windows in #303 by letting the two
conversirons get out of sync.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants