haskell / haskell-ide-engine

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

HIE unresponsive #983

Closed Anrock closed 5 years ago

Anrock commented 5 years ago

I've noticed that somewhere after 8e7d756b commit hie stopped responding to client requests. Unfortunately i'm unable to compile hie on most commits after 8e7d756b, so i can't bisect to specific commit. Not sure if it's a specific request that makes hie freezed or there is some specific trigger

Relevant logs: https://pastebin.com/zLqyGDF0 <- stuck after documentHighlight request, source is compilable. https://pastebin.com/n8zR5PUy <- stuck after didChange request that introduced error in source and another didChange that fixed it back

Anrock commented 5 years ago

UPD: latest working 72bf4c76 first buildable and non-working: 3246eac9

Anrock commented 5 years ago

Recap: something was broken after 72bf4c76 and before 3f01cb42.

And another UPD. Backporting of --with-compiler fix for cabal i was also able to build 3f01cb42 and it was also broken. For other commits in this range i'm getting build failures similar to

 Configuring cabal-helper-0.9.0.0...
    Warning: To use the 'default-language' field the package needs to specify at
    least 'cabal-version: >= 1.10'.
    Warning: To use the 'default-extensions' field the package needs to specify at
    least 'cabal-version: >= 1.10'.
    Cabal-simple_Z6RU0evB_2.2.0.1_ghc-8.4.4.exe: The field 'build-depends:
    cabal-helper' refers to a library which is defined within the same package. To
    use this feature the package must specify at least 'cabal-version: >= 1.8'.

Is there anything else i can try patching during bisecting to get it to build and test if it's work?

tomcur commented 5 years ago

I'm having similar issues, though even 72bf4c7 is not working for me. Here's a log using a build from that commit. This is testing on a stack new project, which was initialized with lts-12.22 (GHC 8.4.4)

2018-12-11 00:01:33.4281489 [ThreadId 3] - Using stack GHC version
2018-12-11 00:01:33.5671511 [ThreadId 3] - Run entered for HIE(hie) Version 0.3.0.0, Git revision 72bf4c76d95e39c91c116d9171a604f636d2bac2 (dirty) (2160 commits) x86_64 ghc-8.4.4
2018-12-11 00:01:33.5681534 [ThreadId 3] - Current directory:G:\Other\temp\testproj
2018-12-11 00:01:33.5681534 [ThreadId 3] - Enabling --vomit for ghc-mod. Output will be on stderr
2018-12-11 00:01:33.5681534 [ThreadId 3] - 

haskell-lsp:Starting up server ...
2018-12-11 00:01:33.5681534 [ThreadId 3] - ---> {"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"capabilities": {"workspace": {"applyEdit": true, "didChangeConfiguration": {}}, "textDocument": {"hover": {"contentFormat": ["markdown", "plaintext"]}, "formatting": {}, "rename": {}, "codeAction": {}, "documentHighlight": {}, "rangeFormatting": {}, "signatureHelp": {"signatureInformation": {"documentationFormat": ["markdown", "plaintext"]}}, "definition": {}, "synchronization": {"didSave": true}, "references": {}, "documentSymbol": {"symbolKind": {"valueSet": [1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14]}}, "completion": {"completionItem": {"snippetSupport": true}, "completionItemKind": {"valueSet": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]}}}}, "rootUri": "file:///G:/Other/temp/testproj", "processId": 20580, "rootPath": "G:\\Other\\temp\\testproj"}}
2018-12-11 00:01:33.5691789 [ThreadId 3] - haskell-lsp:initializeRequestHandler: setting current dir to project root:G:\Other\temp\testproj
2018-12-11 00:01:33.6071936 [ThreadId 5] - <--2--{"result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"willSave":false,"willSaveWaitUntil":false,"save":{"includeText":false}},"workspace":{},"documentRangeFormattingProvider":true,"documentHighlightProvider":true,"executeCommandProvider":{"commands":["22104:applyrefact:applyOne","22104:applyrefact:applyAll","22104:applyrefact:lint","22104:base:version","22104:base:plugins","22104:base:commands","22104:base:commandDetail","22104:brittany:format","22104:build:prepare","22104:build:isConfigured","22104:build:configure","22104:build:listTargets","22104:build:listFlags","22104:build:buildDirectory","22104:build:buildTarget","22104:ghcmod:check","22104:ghcmod:lint","22104:ghcmod:info","22104:ghcmod:type","22104:ghcmod:casesplit","22104:hare:demote","22104:hare:dupdef","22104:hare:iftocase","22104:hare:liftonelevel","22104:hare:lifttotoplevel","22104:hare:rename","22104:hare:deletedef","22104:hare:genapplicative","22104:hare:casesplit","22104:hoogle:info","22104:hoogle:lookup","22104:hsimport:import","22104:liquid:sayHello","22104:liquid:sayHelloTo","22104:package:add","22104:pragmas:addPragma"]},"renameProvider":true,"definitionProvider":true,"hoverProvider":true,"codeActionProvider":true,"completionProvider":{"triggerCharacters":["."],"resolveProvider":true},"documentSymbolProvider":true,"documentFormattingProvider":true,"referencesProvider":true}},"jsonrpc":"2.0","id":1}
2018-12-11 00:01:33.6101554 [ThreadId 3] - ---> {"jsonrpc": "2.0", "method": "textDocument/didOpen", "params": {"textDocument": {"version": 0, "languageId": "haskell", "text": "module Lib\n    ( someFunc\n    ) where\n\nsomeFunc :: IO ()\nsomeFunc = putStrLn \"someFunc\"\n", "uri": "file:///G:/Other/temp/testproj/src/Lib.hs"}}}
2018-12-11 00:01:33.6111585 [ThreadId 3] - ---> {"jsonrpc": "2.0", "method": "initialized", "params": {}}
2018-12-11 00:01:33.6111585 [ThreadId 12] - ****** reactor: got message number:0
2018-12-11 00:01:33.6111585 [ThreadId 12] - ****** reactor: processing NotDidOpenTextDocument
2018-12-11 00:01:33.6111585 [ThreadId 12] - requestDiagnostics: no diagFunc for:DiagnosticOnOpen
2018-12-11 00:01:33.6111585 [ThreadId 12] - ****** reactor: got message number:1
2018-12-11 00:01:33.6111585 [ThreadId 12] - ****** reactor: processing Initialized Notification
2018-12-11 00:01:33.6111585 [ThreadId 12] - Using stack GHC version
2018-12-11 00:01:33.6141515 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"type":4,"message":"Using hie version: Version 0.3.0.0, Git revision 72bf4c76d95e39c91c116d9171a604f636d2bac2 (dirty) (2160 commits) x86_64 ghc-8.4.4"},"method":"window/logMessage"}
2018-12-11 00:01:33.785151 [ThreadId 13] - ghcDispatcher: top of loop
2018-12-11 00:01:33.785151 [ThreadId 13] - ghcDispatcher:got request 0 with id: Nothing
2018-12-11 00:01:33.785151 [ThreadId 14] - ideDispatcher: top of loop
2018-12-11 00:01:33.932151 [ThreadId 13] - file mapping state is: fromList [("G:\\Other\\temp\\testproj\\src\\Lib.hs",FileMapping {fmPath = "C:\\Users\\Thomas\\AppData\\Local\\Temp\\ghc-mod22105\\LibB1FD.hs", fmTemp = True})]
2018-12-11 00:01:33.9331509 [ThreadId 13] - ghcDispatcher: top of loop
2018-12-11 00:01:33.9331509 [ThreadId 13] - ghcDispatcher:got request 0 with id: Nothing
2018-12-11 00:01:33.9331509 [ThreadId 13] - ghcDispatcher:Processing request as version matches
2018-12-11 00:01:33.9971508 [ThreadId 13] - ghcDispatcher: top of loop
2018-12-11 00:01:33.9981553 [ThreadId 13] - ghcDispatcher:got request 0 with id: Nothing
2018-12-11 00:01:33.9981553 [ThreadId 13] - ghcDispatcher:Processing request as version matches
2018-12-11 00:01:33.9981553 [ThreadId 13] - setTypecheckedModule: file mapping state is: fromList [("G:\\Other\\temp\\testproj\\src\\Lib.hs",FileMapping {fmPath = "C:\\Users\\Thomas\\AppData\\Local\\Temp\\ghc-mod22105\\LibB1FD.hs", fmTemp = True})]
2018-12-11 00:01:33.9981553 [ThreadId 13] - setTypecheckedModule: before ghc-mod
2018-12-11 00:01:34.097156 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"uri":"file:///G%3A/Other/temp/testproj/src/Lib.hs","diagnostics":[]},"method":"textDocument/publishDiagnostics"}
2018-12-11 00:01:56.2301515 [ThreadId 3] - ---> {"jsonrpc": "2.0", "id": 2, "method": "textDocument/hover", "params": {"textDocument": {"uri": "file:///G:/Other/temp/testproj/src/Lib.hs"}, "position": {"line": 5, "character": 14}}}
2018-12-11 00:02:01.2630049 [ThreadId 3] - ---> {"jsonrpc": "2.0", "id": 3, "method": "textDocument/hover", "params": {"textDocument": {"uri": "file:///G:/Other/temp/testproj/src/Lib.hs"}, "position": {"line": 5, "character": 14}}}
2018-12-11 00:02:41.0151424 [ThreadId 3] - ---> {"jsonrpc": "2.0", "id": 4, "method": "textDocument/hover", "params": {"textDocument": {"uri": "file:///G:/Other/temp/testproj/src/Lib.hs"}, "position": {"line": 5, "character": 17}}}
2018-12-11 00:02:59.769161 [ThreadId 3] - ---> {"jsonrpc": "2.0", "id": 5, "method": "textDocument/formatting", "params": {"options": {"insertSpaces": true, "tabSize": 4}, "textDocument": {"uri": "file:///G:/Other/temp/testproj/src/Lib.hs"}}}
2018-12-11 00:03:34.7026554 [ThreadId 3] - ---> {"jsonrpc": "2.0", "method": "textDocument/didClose", "params": {"textDocument": {"uri": "file:///G:/Other/temp/testproj/src/Lib.hs"}}}
2018-12-11 00:03:34.7196536 [ThreadId 3] - ---> {"jsonrpc": "2.0", "id": 6, "method": "shutdown"}
2018-12-11 00:03:34.7196536 [ThreadId 5] - <--2--{"error":{"code":-32603,"message":"haskell-lsp:parse error. Object (fromList [(\"jsonrpc\",String \"2.0\"),(\"method\",String \"shutdown\"),(\"id\",Number 6.0)]) \"When parsing the record RequestMessage of type Language.Haskell.LSP.Types.Message.RequestMessage the key params was not present.\" `stack update` and install new haskell-lsp. Or check information on https://marketplace.visualstudio.com/items?itemName=xxxxxxxxxxxxxxx"},"jsonrpc":"2.0","id":6}
2018-12-11 00:03:34.7336563 [ThreadId 3] - 
haskell-lsp:Got EOF, exiting 1 ...

Note, at 2018-12-11 00:03:34 I closed the editor.

alanz commented 5 years ago

How did you install hie? The makefile now makes sure to install cabal-install, and Cabal-2.4.1.0.

These are needed to enable GHC 8.6 / cabal-helper support.

tomcur commented 5 years ago

@alanz I manually ran outside the project directory:

> stack install cabal-install
> cabal update
> stack --stack-yaml=stack-8.4.4.yaml install happy
> stack --stack-yaml=stack-8.4.4.yaml install

Note I'm using GHC 8.4.4. The projects I've tried this on are using lts-12.22. Is cabal-install 2.4.1.0 also required for that? Currently I have:

> cabal --version
cabal-install version 2.2.0.0
compiled using version 2.2.0.1 of the Cabal library
Anrock commented 5 years ago

@alanz via make-target, along with hie-8.4.4.

>cabal --version
cabal-install version 2.4.1.0
compiled using version 2.4.1.0 of the Cabal library
alanz commented 5 years ago

It there a windows user who can look into this or comment?

LukaHorvat commented 5 years ago

I'm a Windows user but I can't do much more than confirm that I'm also not getting any output. I think that issue I opened (https://github.com/haskell/haskell-ide-engine/issues/969) is the same as this one.

stouf commented 5 years ago

I think I'm facing the same issue. I'm trying to use hie with this language-server client on Archlinux. I installed hie through AUR. Here are some of the logs I can see:

2019-01-04 18:27:23.649974915 [ThreadId 10] - requestDiagnostics: no diagFunc for:DiagnosticOnOpen
2019-01-04 18:27:23.650015234 [ThreadId 10] - ****** reactor: top of loop
2019-01-04 18:27:23.650048613 [ThreadId 12] - ghcDispatcher:got request 0 with id: Nothing
2019-01-04 18:27:23.650160518 [ThreadId 12] - ghcDispatcher: top of loop
2019-01-04 18:27:23.650198566 [ThreadId 12] - ghcDispatcher:got request 1 with id: Nothing
2019-01-04 18:27:23.651924556 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"type":2,"message":"No hoogle db found. Check the README for instructions to generate one"},"method":"window/showMessage"}
2019-01-04 18:27:23.911898641 [ThreadId 12] - file mapping state is: fromList [("/path/to/file.hs",FileMapping {fmPath = "/tmp/ghc-mod3077/DbConfig3076-0.hs", fmTemp = True})]
2019-01-04 18:27:23.912013551 [ThreadId 12] - ghcDispatcher: top of loop
2019-01-04 18:27:23.912055014 [ThreadId 12] - ghcDispatcher:got request 1 with id: Nothing
2019-01-04 18:27:23.912090151 [ThreadId 12] - ghcDispatcher:Processing request as version matches
2019-01-04 18:27:35.253451002 [ThreadId 4] - ---> {"jsonrpc":"2.0","method":"textDocument/hover","params":{"position":{"character":2,"line":35},"textDocument":{"uri":"file:///path/to/file.hs"}},"id":18}
2019-01-04 18:27:35.253840498 [ThreadId 10] - ****** reactor: got message number:2
Message: {"jsonrpc":"2.0","method":"textDocument/formatting","params":{"bufnr":1,"character":0,"filename":"/path/to/file.hs","handle":true,"languageId":"haskell","line":35,"text":["module Config.DbConfig (","  read_,","  host,","  port,","  user,","  password,","  name,","  connectionLimit,","  InvalidNumber(..)",") where","","import Control.Exception.Base","import System.Environment","import Text.Read","","data InvalidNumber =","  InvalidPort String","  | InvalidConnectionLimit String","  deriving (Show)","instance Exception InvalidNumber","","data DbConfig = DbConfig {","  host :: String,","  port :: Int,","  user :: String,","  password :: String,","  name :: String,","  connectionLimit :: Int","} deriving (Show)","","strToInt :: String -> Maybe Int","strToInt = readMaybe","","read_ :: IO (DbConfig)","read_ = do","  host <- getEnv \"DB_HOST\"","  portStr <- getEnv \"DB_PORT\"","  user <- getEnv \"DB_USER\"","  password <- getEnv \"DB_PASSWORD\"","  name <- getEnv \"DB_NAME\"","  connectionLimitStr <- getEnv \"DB_CONNECTION_LIMIT\"","  case ((strToInt portStr), (strToInt connectionLimitStr)) of","    (Nothing, _) -> throw (InvalidPort portStr)","    (_, Nothing) -> throw (InvalidConnectionLimit connectionLimitStr)","    (Just port, Just connectionLimit) -> return (DbConfig {","      host=host,","      port=port,","      user=user,","      password=password,","      name=name,","      connectionLimit=connectionLimit","    })",""]},"id":3}

Error: Timeout
18:36:21 INFO main src/vim.rs:93 => None {"jsonrpc":"2.0","error":{"code":-32603,"message":"timed out waiting on channel"},"id":3}

I'm new to Haskell and to hie but it looks like hie receives requests from the language-server client but doens't reply right?

Version of GHC: 8.6.3

rossng commented 5 years ago

I did some digging into this and it seems like the issue is caused in cabal-helper commit a3fcfed6743806c842ffe9d253da3f695aa4799c, when the line:

  scope:               private

is commented out. Uncommenting this line on the latest master made vscode-hie-server work for me again. To be clear, that means the block will look like this in submodules\cabal-helper\cabal-helper.cabal, lines 119-124:

executable cabal-helper-wrapper
  main-is:             CabalHelper/Compiletime/Wrapper.hs
  if flag(dev)
    ghc-options:         -Wall
  scope:               private
  -- x-scope:               private

(Warning: I am not a Cabal nerd and I haven't looked into what the purpose of this line actually is - probably best if someone more experienced could also chip in!)

My setup: Win10, VS Code, GHC 8.2.2.

asadoll commented 5 years ago

@rossng I just made the same change in cabal-helper.cabal and everything works fine with GHC 8.4.4 I try to build HIE for 8.6.2 (8.6.3 doesn't compile) and update this thread with the results.

My setup: Win10, spacemacs, GHC 8.4.4

asadoll commented 5 years ago

@rossng I just made the same change in cabal-helper.cabal and everything works fine with GHC 8.4.4 I try to build HIE for 8.6.2 (8.6.3 doesn't compile) and update this thread with the results.

My setup: Win10, spacemacs, GHC 8.4.4

GHC 8.6.2 also works as expected.

Anrock commented 5 years ago

@alanz any news on this?

KillyMXI commented 5 years ago

Win10, VScode, GHC-8.4.4

Following the comment https://github.com/haskell/haskell-ide-engine/issues/983#issuecomment-457882300 I uncommented the line with the scope and rebuilt hie (stack .\install.hs hie-8.4.4). After opening VScode I got following: In popup notification:

Got error while processing diagnostics: readCreateProcess: C:\Programs\hie\haskell-ide-engine\.stack-work\install\6835b01e\libexec\x86_64-windows-ghc-8.4.4\cabal-helper-0.9.0.0\cabal-helper-wrapper.exe "print-build-platform" (exit 1): failed

In extension output:

cabal-helper-wrapper.exe: dieVerbatim: user error (cabal-helper-wrapper.exe: The program 'ghc' version >=6.11 is required but it
could not be found.

This looks like https://github.com/alanz/vscode-hie-server/issues/128 and #1004. After applying the workaround from the first of these (adding stack ghc binaries folder to path environment), it now seems to work mostly. When I go through hlint reports and hover over a reported line with import - it shows hlint message in popup, but also a "Loading..." message. After that, any popup will shown nothing else but "Loading...". As long as I avoid import lines, popups seem to work fine. Can't provide logs for that before I figure out how to enable debug/vomit mode with vscode extension.

jneira commented 5 years ago

Not sure 100% if it was the solution but i get to load cabal and stack based projects in vscode-1.33.0 (ext version 0.0.25) for windows 7 (ghc-8.6.2) and 10 (ghc-8.6.4) after installing locally the fix to make hie-wrapper find the cabal-helper-wrapper: https://github.com/alanz/cabal-helper/pull/5 Before that change the cabal project throwed an error and the stack one simply hanged out as described in #1166 They started to work with the master version after setting the cabal_helper_libexecdir with the correct path to cabal-helper too.

jneira commented 5 years ago

Maybe we could close this one, do you continue hitting the original unresponsive behaviour in windows @Anrock?

Anrock commented 5 years ago

@jneira no, on 8.6.5 I no longer hit it