Description
(This is more of a support issue, I think)
I am currently using lsp-test library and instructions provided while trying to extend hls/ghcide. I was trying to start with the simple examples provided on the lsp-test wiki/github pages. When, I try to execute the simplest example, I see that a 'shutdown' command is sent immediately.
So, far I have gone through tests inside ghcide to see if there is something different being done to avoid this situation. I just cam across the use of ( >> expectNoMoreDiagnostics 0.5)
, but even that does not seem to help.
Am I doing something wrong?
Subject of the issue
shutdown message sent my test-lsp while trying to write a simple test.
Your environment
- Output of
haskell-language-server --probe-tools
orhaskell-language-server-wrapper --probe-tools
cabal: 2.4.1.0
stack: 2.3.1
ghc: 8.8.3
-
Which lsp-client do you use
lsp-test library -
Describe your project (alternative: link to the project)
main = runSession "haskell-language-server-wrapper --lsp" fullCaps "." $ do
--liftIO $ putStrLn "Inside runSession"
doc <- openDoc "app/test-lsp.hs" "haskell"
liftIO $ print "out"
Here is the outout of this script
test-lsp-exe: Couldn't decode response for the request type: Shutdown
"{\"result\":null,\"jsonrpc\":\"2.0\",\"id\":0}"
CallStack (from HasCallStack):
error, called at src/Language/Haskell/LSP/Test/Decoding.hs:120:32 in lsp-test-0.6.1.0-F6ZpWvHwbB8IOsvsvivYhC:Language.Haskell.LSP.Test.Decoding
Steps to reproduce
Running this code sends the 'textDocument/didOpen' method and then immediately send ''shutdown' method.
Expected behaviour
I would expect to be able to use the return value from openDoc to send further requests.
Actual behaviour
'shutdown' method sent too early.
here is the lsp log.
haskell-lsp:Starting up server ...
2020-09-19 21:06:32.695884694 [ThreadId 5] - ---> {"jsonrpc":"2.0","params":{"rootUri":"file:///home/devanla/fsf/haskell-scratch","processId":11548,"rootPath":"/home/devanla/fsf/haskell-scratch","capabilities":{"workspace":{"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"dynamicRegistration":true},"workspaceEdit":{"documentChanges":true},"didChangeConfiguration":{"dynamicRegistration":true},"applyEdit":true,"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true,"configuration":true},"textDocument":{"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"preselectSupport":true,"commitCharactersSupport":true,"snippetSupport":true,"deprecatedSupport":true,"documentationFormat":["plaintext","markdown"]},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"documentHighlight":{"dynamicRegistration":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"didSave":true,"willSaveWaitUntil":true},"definition":{"dynamicRegistration":true},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"ocumentationFormat":["plaintext","markdown"]}},"references":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":true},"foldingRange":{"lineFoldingOnly":false,"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"codeLens":{"dynamicRegistration":true},"documentSymbol":{"hierarchicalDocumentSymbolSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"implementation":{"dynamicRegistration":true},"typeDefinition":{"dynamicRegistration":true},"publishDiagnostics":{"relatedInformation":true},"rename":{"dynamicRegistration":true},"hover":{"contentFormat":["plaintext","markdown"],"dynamicRegistration":true}}},"trace":"off"},"method":"initialize","id":0}
2020-09-19 21:06:32.696592477 [ThreadId 5] - haskell-lsp:initializeRequestHandler: setting current dir to project root:/home/devanla/fsf/haskell-scratch
2020-09-19 21:06:32.710227193 [ThreadId 7] - <--2--{"result":{"capabilities":{"typeDefinitionProvider":true,"foldingRangeProvider":false,"textDocumentSync":{"openClose":true,"change":2,"save":{}},"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true}},"implementationProvider":true,"documentRangeFormattingProvider":true,"documentHighlightProvider":true,"executeCommandProvider":{"commands":["11581:eg:codelens.todo1","11581:eg2:codelens.todo","11581:eval:evalCommand","11581:ghcide:typesignature.add","11581:importLens:ImportLensCommand","11581:pragmas:addPragma","11581:retrie:retrieCommand"]},"renameProvider":false,"colorProvider":false,"definitionProvider":true,"hoverProvider":true,"codeActionProvider":true,"completionProvider":{"triggerCharacters":["."],"resolveProvider":false},"codeLensProvider":{},"documentSymbolProvider":true,"documentFormattingProvider":true}},"jsonrpc":"2.0","id":0}
2020-09-19 21:06:32.710878796 [ThreadId 5] - ---> {"jsonrpc":"2.0","method":"initialized","params":{}}
2020-09-19 21:06:32.711795692 [ThreadId 5] - ---> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///home/devanla/fsf/haskell-scratch/app/test-lsp.hs","languageId":"haskell","version":0,"text":"{-# LANGUAGE NoImplicitPrelude #-}\n{-# LANGUAGE OverloadedStrings #-}\n{-# LANGUAGE ExistentialQuantification #-}\n{-# LANGUAGE GADTs #-}\n{-# LANGUAGE RankNTypes #-}\n{-# OPTIONS_GHC -Werror=missing-fields #-}\n\n\nmodule Main (main)\n where\n\n--import Prelude.Compat\nimport Prelude\nimport Language.Haskell.LSP.Test\nimport Language.Haskell.LSP.Types\nimport Control.Monad.IO.Class\nimport Control.Applicative.Combinators\nimport System.Time.Extra\n\ndata TestSumType = TestSumType1 Int | TestSumType2 Bool\n\ndata X = X {\n firstValue :: Integer,\n secondValue :: String\n } deriving (Show)\n\n\n--x = X {hea}\n\n-- y :: String\n-- y = let\n-- z = X { firstValue=100, se }\n-- in\n-- someFunc \"test\"\n\n-- someFunc :: Int\n-- someFunc = \"test\"\n\n-- main :: IO ()\n-- main = runSession \"haskell-language-server\" fullCaps \".\" $ do\n-- doc <- openDoc \"test-lsp.hs\" \"haskell\"\n-- getDocumentSymbols doc >>= liftIO putStrLn\n\nmain = runSession \"haskell-language-server --lsp -d -l /tmp/t.log -j 0\" fullCaps \".\" $ do\n --liftIO $ putStrLn \"Inside runSession\"\n doc <- openDoc \"app/test-lsp.hs\" \"haskell\"\n --msg1 <- message\n --liftIO $ putStrLn msg1\n --msg2 <- message\n --msg3 <- message\n --liftIO $ putStrLn msg1\n liftIO $ print \"out\"\n --liftIO $ putStrLn \"Got doc\"\n --liftIO $ sleep 25\n --symbols <- getDocumentSymbols doc\n --liftIO $ sleep 25\n --liftIO . print $ symbols\n --liftIO $ sleep 25\n --liftIO $ putStrLn \"after trying to print doc\"\n --liftIO . print $ \"done\"\n --liftIO $ sleep 10\n\n -- diags <- getDefinitions doc (Position 4 5)\n -- rename doc (Position 2 3) \"howdy\"\n -- liftIO $ putStrLn \"Got doc\"\n -- documentContents doc >>= liftIO . print\n\n\n--import Language.Haskell.LSP.Test\n\n-- main = runSession \"haskell-language-server\" fullCaps \".\" $ do\n-- doc <- openDoc \"test-lsp.hs\" \"haskell\"\n-- skipMany anyNotification\n-- symbols <- getDocumentSymbols doc\n\n\n-- {\"result\":\n-- [\n\n-- {\"edit\":{\"changes\":{\"file:///home/devanla/fsf/haskell-scratch/app/test-lsp.hs\":[{\"range\":{\"start\":{\"line\":2,\"character\":0},\"end\":{\"line\":2,\"character\"\n-- :0}},\"newText\":\"-- TODO1 added by Example Plugin directly\\n\"}]}},\"kind\":\"quickfix\",\"diagnostics\":[],\"title\":\"Add TODO Item 1\"},\n\n\n-- {\"edit\":{\"changes\":{\"file:///home/devanla/fsf/haskell-scratch/app/test-lsp.hs\":[{\"range\":{\"start\":{\"line\":3,\"character\":0},\"end\":{\"line\":3,\"character\":0}},\"newText\":\"-- TODO2 added by Example2 Plugin directly\\n\"}]}},\"kind\":\"quickfix\",\"diagnostics\":[],\"title\":\"Add TODO2 Item\"},\n\n-- {\"edit\":{\"changes\":{\"file:///home/devanla/fsf/haskell-scratch/app/test-lsp.hs\":[{\"range\":{\"start\":{\"line\":23,\"character\":27},\"end\":{\"line\":23,\"character\":29}},\"newText\":\"seq\"}]}},\n-- \"kind\":\"quickfix\",\n-- \"diagnostics\":[{\"severity\":1,\"range\":{\"start\":{\"line\":23,\"character\":27},\"end\":{\"line\":23,\"character\":29}},\"source\":\"typecheck\",\"message\":\"Not in scope: ‘se’\\nPerhaps you meant ‘seq’ (imported from Prelude)\"}],\n-- \"title\":\"Replace with ‘seq’\"}\n-- ],\n-- \"jsonrpc\":\"2.0\",\"id\":2895\n\n-- }\n"}}}
2020-09-19 21:06:32.712232419 [ThreadId 5] - ---> {"jsonrpc":"2.0","params":null,"method":"shutdown","id":0}
2020-09-19 21:06:32.712330803 [ThreadId 7] - <--2--{"result":null,"jsonrpc":"2.0","id":0}
Include debug information
haskell-language-server version: 0.4.0.0 (GHC: 8.6.5) (PATH: /home/projectdir/hls/.stack-work/install/x86_64-linux/24d08e207078ccd6be7414f4a4f95bd8b39e9f8383f7062388065ca9690064e0/8.6.5/bin/haskell-language-server) (GIT hash: 1d1ab3bad0d6d0528b8cdeaa697836b18508b596)
(haskell-language-server)Ghcide setup tester in /home/projectdir/haskell-scratch.
Report bugs at https://github.com/haskell/haskell-language-server/issues
Tool versions found on the $PATH
cabal: 2.4.1.0
stack: 2.3.1
ghc: 8.8.3
Step 1/4: Finding files to test in /home/projectdir/haskell-scratch
Found 7 files
Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
Step 3/4: Initializing the IDE
Step 4/4: Type checking the files
[INFO] Consulting the cradle for "/home/projectdir/haskell-scratch/src/Lib.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/projectdir/haskell-scratch", cradleOptsProg = CradleAction: Stack}
> haskell-scratch> configure (lib + exe)
> Configuring haskell-scratch-0.1.0.0...
> haskell-scratch> initial-build-steps (lib + exe)
> Configuring GHCi with the following packages: haskell-scratch
> /home/projectdir/haskell-scratch/.stack-work/install/x86_64-linux/6bd03d3d5aa2731befe8d581bb72b77c811fbf366241823de3e19a5b0ebb420e/8.6.5/pkgdb:/home/foouser/.stack/snapshots/x86_64-linux/6bd03d3d5aa2731befe8d581bb72b77c811fbf366241823de3e19a5b0ebb420e/8.6.5/pkgdb:/home/foouser/.stack/programs/x86_64-linux/ghc-8.6.5/lib/ghc-8.6.5/package.conf.d
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-e9952cbdc286fc435c93089a3556ddb602aaa0b5
[INFO] Making new HscEnv[main]
[INFO] Consulting the cradle for "/home/projectdir/haskell-scratch/app/test-lsp.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/projectdir/haskell-scratch", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `haskell-scratch' component haskell-scratch:exe:test-lsp-exe with main-is file: /home/projectdir/haskell-scratch/app/test-lsp.hs
> haskell-scratch> configure (lib + exe)
> Configuring haskell-scratch-0.1.0.0...
> haskell-scratch> initial-build-steps (lib + exe)
> The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
> Configuring GHCi with the following packages: haskell-scratch
> /home/projectdir/haskell-scratch/.stack-work/install/x86_64-linux/6bd03d3d5aa2731befe8d581bb72b77c811fbf366241823de3e19a5b0ebb420e/8.6.5/pkgdb:/home/foouser/.stack/snapshots/x86_64-linux/6bd03d3d5aa2731befe8d581bb72b77c811fbf366241823de3e19a5b0ebb420e/8.6.5/pkgdb:/home/foouser/.stack/programs/x86_64-linux/ghc-8.6.5/lib/ghc-8.6.5/package.conf.d
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-a2d526d4313478529253b6a17980d618b7198e76
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-a2d526d4313478529253b6a17980d618b7198e76
[INFO] Making new HscEnv[main,main]
[INFO] Consulting the cradle for "/home/projectdir/haskell-scratch/app/main.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/projectdir/haskell-scratch", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `haskell-scratch' component haskell-scratch:exe:haskell-scratch-exe with main-is file: /home/projectdir/haskell-scratch/app/main.hs
> haskell-scratch> configure (lib + exe)
> Configuring haskell-scratch-0.1.0.0...
> haskell-scratch> initial-build-steps (lib + exe)
> The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
> Configuring GHCi with the following packages: haskell-scratch
> /home/projectdir/haskell-scratch/.stack-work/install/x86_64-linux/6bd03d3d5aa2731befe8d581bb72b77c811fbf366241823de3e19a5b0ebb420e/8.6.5/pkgdb:/home/foouser/.stack/snapshots/x86_64-linux/6bd03d3d5aa2731befe8d581bb72b77c811fbf366241823de3e19a5b0ebb420e/8.6.5/pkgdb:/home/foouser/.stack/programs/x86_64-linux/ghc-8.6.5/lib/ghc-8.6.5/package.conf.d
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-33322b2a0d073962cdeed87e764f3d1ded942ce9
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-33322b2a0d073962cdeed87e764f3d1ded942ce9
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-33322b2a0d073962cdeed87e764f3d1ded942ce9
[INFO] Making new HscEnv[main,main,main]
[INFO] Consulting the cradle for "/home/projectdir/haskell-scratch/Setup.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/projectdir/haskell-scratch", cradleOptsProg = CradleAction: Stack}
File: /home/projectdir/haskell-scratch/Setup.hs
Hidden: no
Range: 1:0-2:0
Source: cradle
Severity: DsError
Message:
�[0;91mMulti Cradle: No prefixes matched
pwd: /home/projectdir/haskell-scratch
filepath: /home/projectdir/haskell-scratch/Setup.hs
prefixes:
("./src",Stack {component = Just "haskell-scratch:lib"})
("././app/datatypes-alacarte.hs",Stack {component = Just
"haskell-scratch:exe:datatypes-alacarte-exe"})
("././Paths_haskell_scratch.hs",Stack {component = Just
"haskell-scratch:exe:datatypes-alacarte-exe"})
("././app/main.hs",Stack {component = Just "haskell-scratch:exe:haskell-scratch-exe"})
("././Paths_haskell_scratch.hs",Stack {component = Just
"haskell-scratch:exe:haskell-scratch-exe"})
("././app/test-lsp.hs",Stack {component = Just "haskell-scratch:exe:test-lsp-exe"})
("././Paths_haskell_scratch.hs",Stack {component = Just "haskell-scratch:exe:test-lsp-exe"})
("./test",Stack {component = Just "haskell-scratch:test:haskell-scratch-test"})�[0m
[INFO] Consulting the cradle for "/home/projectdir/haskell-scratch/app/devanla@is-devanla-01.25598:1599772457"
Output from setting up the cradle Cradle {cradleRootDir = "/home/projectdir/haskell-scratch", cradleOptsProg = CradleAction: Stack}
File: /home/projectdir/haskell-scratch/app/devanla@is-devanla-01.25598:1599772457
Hidden: no
Range: 1:0-2:0
Source: cradle
Severity: DsError
Message:
�[0;91mMulti Cradle: No prefixes matched
pwd: /home/projectdir/haskell-scratch
filepath: /home/projectdir/haskell-scratch/app/devanla@is-devanla-01.25598:1599772457
prefixes:
("./src",Stack {component = Just "haskell-scratch:lib"})
("././app/datatypes-alacarte.hs",Stack {component = Just
"haskell-scratch:exe:datatypes-alacarte-exe"})
("././Paths_haskell_scratch.hs",Stack {component = Just
"haskell-scratch:exe:datatypes-alacarte-exe"})
("././app/main.hs",Stack {component = Just "haskell-scratch:exe:haskell-scratch-exe"})
("././Paths_haskell_scratch.hs",Stack {component = Just
"haskell-scratch:exe:haskell-scratch-exe"})
("././app/test-lsp.hs",Stack {component = Just "haskell-scratch:exe:test-lsp-exe"})
("././Paths_haskell_scratch.hs",Stack {component = Just "haskell-scratch:exe:test-lsp-exe"})
("./test",Stack {component = Just "haskell-scratch:test:haskell-scratch-test"})�[0m
[INFO] Consulting the cradle for "/home/projectdir/haskell-scratch/app/datatypes-alacarte.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/projectdir/haskell-scratch", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `haskell-scratch' component haskell-scratch:exe:datatypes-alacarte-exe with main-is file: /home/projectdir/haskell-scratch/app/datatypes-alacarte.hs
> haskell-scratch> configure (lib + exe)
> Configuring haskell-scratch-0.1.0.0...
> haskell-scratch> initial-build-steps (lib + exe)
> The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
> Configuring GHCi with the following packages: haskell-scratch
> /home/projectdir/haskell-scratch/.stack-work/install/x86_64-linux/6bd03d3d5aa2731befe8d581bb72b77c811fbf366241823de3e19a5b0ebb420e/8.6.5/pkgdb:/home/foouser/.stack/snapshots/x86_64-linux/6bd03d3d5aa2731befe8d581bb72b77c811fbf366241823de3e19a5b0ebb420e/8.6.5/pkgdb:/home/foouser/.stack/programs/x86_64-linux/ghc-8.6.5/lib/ghc-8.6.5/package.conf.d
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-c4fd1db97bfc19a35e00fb51bb42880ec41b2dec
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-c4fd1db97bfc19a35e00fb51bb42880ec41b2dec
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-c4fd1db97bfc19a35e00fb51bb42880ec41b2dec
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-c4fd1db97bfc19a35e00fb51bb42880ec41b2dec
[INFO] Making new HscEnv[main,main,main,main]
[INFO] Consulting the cradle for "/home/projectdir/haskell-scratch/Setup.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/projectdir/haskell-scratch", cradleOptsProg = CradleAction: Stack}
[INFO] Consulting the cradle for "/home/projectdir/haskell-scratch/app/devanla@is-devanla-01.25598:1599772457"
Output from setting up the cradle Cradle {cradleRootDir = "/home/projectdir/haskell-scratch", cradleOptsProg = CradleAction: Stack}
[INFO] Consulting the cradle for "/home/projectdir/haskell-scratch/test/Spec.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/projectdir/haskell-scratch", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `haskell-scratch' component haskell-scratch:test:haskell-scratch-test with main-is file: /home/projectdir/haskell-scratch/test/Spec.hs
> haskell-scratch> configure (lib + exe)
> Configuring haskell-scratch-0.1.0.0...
> haskell-scratch> initial-build-steps (lib + exe)
> The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
> Configuring GHCi with the following packages: haskell-scratch
>
> Warning: Didn't find expected autogen file:
> /home/projectdir/haskell-scratch/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/haskell-scratch-test/autogen/cabal_macros.h
> /home/projectdir/haskell-scratch/.stack-work/install/x86_64-linux/6bd03d3d5aa2731befe8d581bb72b77c811fbf366241823de3e19a5b0ebb420e/8.6.5/pkgdb:/home/foouser/.stack/snapshots/x86_64-linux/6bd03d3d5aa2731befe8d581bb72b77c811fbf366241823de3e19a5b0ebb420e/8.6.5/pkgdb:/home/foouser/.stack/programs/x86_64-linux/ghc-8.6.5/lib/ghc-8.6.5/package.conf.d
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-70c8fb3574fcf2be2d0fc89a5880b71d3f3cedc6
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-70c8fb3574fcf2be2d0fc89a5880b71d3f3cedc6
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-70c8fb3574fcf2be2d0fc89a5880b71d3f3cedc6
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-70c8fb3574fcf2be2d0fc89a5880b71d3f3cedc6
[INFO] Using interface files cache dir: /home/foouser/.cache/ghcide/main-70c8fb3574fcf2be2d0fc89a5880b71d3f3cedc6
[INFO] Making new HscEnv[main,main,main,main,main]
[INFO] Consulting the cradle for "/home/projectdir/haskell-scratch/Setup.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/projectdir/haskell-scratch", cradleOptsProg = CradleAction: Stack}
[INFO] Consulting the cradle for "/home/projectdir/haskell-scratch/app/devanla@is-devanla-01.25598:1599772457"
Output from setting up the cradle Cradle {cradleRootDir = "/home/projectdir/haskell-scratch", cradleOptsProg = CradleAction: Stack}
Files that failed:
* /home/projectdir/haskell-scratch/Setup.hs
* /home/projectdir/haskell-scratch/app/devanla@is-devanla-01.25598:1599772457
Completed (5 files worked, 2 files failed)