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

Error in $.params.processId: parsing Int32 failed, expected Number, but encountered Object #160

Closed
joseedil opened this issue Nov 17, 2022 · 5 comments

Comments

@joseedil
Copy link

Your environment

Which OS do you use?
MacOS 12.6.1
Which version of GHC do you use and how did you install it?
9.0.2 from ghcup
How is your project built (alternative: link to the project)?
stack (resolver: lts-19.33) - ghc 9.0.2

Which LSP client (editor/plugin) do you use?
emacs+eglot (but the same happens on lsp-mode)
Which version of HLS do you use and how did you install it?
1.8.0.0 from ghcup
Have you configured HLS in any way (especially: a hie.yaml file)?

Steps to reproduce

Create new project with stack new my-project new-template.
Adjust resolver to lts-19.33
Open project with emacs and load eglot.

Expected behaviour

LSP server should connect to haskell-language-server and do its thing.

Actual behaviour

The client indeed connects to the server, but it crashes whenever you try to use it.
For instance, open src/Lib.hs and hover over the putStrLn usage to get typing information and the server crashes with a message similar to
Server lsp-haskell:32993/starting exited (check corresponding stderr buffer for details). Do you want to restart it? (y or n)

Restarting the server makes it work for a few seconds and crash again in the same manner.

Not sure if the issue is related to haskell-language-server itself or the emacs client.

The VS Code extension works fine in the same project taking the same server from ghcup.

Debug information

stderr output

Notice the error in the last line.

No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.8.0.0 x86_64 ghc-9.4.2
Current directory: /Users/jose.edil/2-development/haskell/helloworld
Operating system: darwin
Arguments: ["--lsp"]
Cradle directory: /Users/jose.edil/2-development/haskell/helloworld
Cradle type: Stack

Tool versions found on the $PATH
cabal:          3.8.1.0
stack:          2.9.1
ghc:            9.0.2


Consulting the cradle to get project GHC version...
Project GHC version: 9.0.2
haskell-language-server exe candidates: ["haskell-language-server-9.0.2","haskell-language-server"]
Launching haskell-language-server exe at:/Users/jose.edil/.ghcup/bin/haskell-language-server-9.0.2
2022-11-17T02:39:38.738801Z | Info | No log file specified; using stderr.
2022-11-17T02:39:38.739711Z | Info | haskell-language-server version: 1.8.0.0 (GHC: 9.0.2) (PATH: /Users/jose.edil/.ghcup/hls/1.8.0.0/lib/haskell-language-server-1.8.0.0/bin/haskell-language-server-9.0.2)
2022-11-17T02:39:38.740439Z | Info | Directory: /Users/jose.edil/2-development/haskell/helloworld
2022-11-17T02:39:38.740764Z | Info | Starting (haskell-language-server) LSP server...
  GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}
  PluginIds: [ pragmas
             , LSPRecorderCallback
             , rename
             , ghcide-completions
             , class
             , refineImports
             , splice
             , changeTypeSignature
             , qualifyImportedNames
             , alternateNumberFormat
             , hlint
             , ghcide-code-actions-fill-holes
             , floskell
             , ghcide-extend-import-action
             , codeRange
             , haddockComments
             , importLens
             , retrie
             , ghcide-type-lenses
             , ghcide-code-actions-imports-exports
             , ghcide-hover-and-symbols
             , eval
             , gadt
             , fourmolu
             , tactics
             , callHierarchy
             , stylish-haskell
             , ghcide-code-actions-type-signatures
             , ghcide-code-actions-bindings
             , moduleName
             , ormolu
             , ghcide-core
             , explicitFixity ]
2022-11-17T02:39:38.744893Z | Info | Logging heap statistics every 60.00s
 2022-11-17T02:39:38.846623Z | Info | Starting LSP server...
  If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option!
  PluginIds: [ pragmas
             , LSPRecorderCallback
             , rename
             , ghcide-completions
             , class
             , refineImports
             , splice
             , changeTypeSignature
             , qualifyImportedNames
             , alternateNumberFormat
             , hlint
             , ghcide-code-actions-fill-holes
             , floskell
             , ghcide-extend-import-action
             , codeRange
             , haddockComments
             , importLens
             , retrie
             , ghcide-type-lenses
             , ghcide-code-actions-imports-exports
             , ghcide-hover-and-symbols
             , eval
             , gadt
             , fourmolu
             , tactics
             , callHierarchy
             , stylish-haskell
             , ghcide-code-actions-type-signatures
             , ghcide-code-actions-bindings
             , moduleName
             , ormolu
             , ghcide-core
             , explicitFixity ]
2022-11-17T02:39:38.846958Z | Info | Starting server
2022-11-17T02:39:38.848191Z | Error | Got error while decoding initialize:
Error in $.params.processId: parsing Int32 failed, expected Number, but encountered Object

LSP log: lsp-haskell:32993

Notice the processId: null at the beginning.
In that specific session haskell-language-server had pid 32993.

[Trace - 11:39:29 PM] Sending request 'initialize - (1)'.
Params: {
  "processId": null,
  "rootPath": "/Users/jose.edil/2-development/haskell/helloworld",
  "clientInfo": {
    "name": "emacs",
    "version": "GNU Emacs 28.2 (build 1, x86_64-apple-darwin21.6.0, Carbon Version 165 AppKit 2113.6)\n of 2022-11-16"
  },
  "rootUri": "file:///Users/jose.edil/2-development/haskell/helloworld",
  "capabilities": {
    "workspace": {
      "workspaceEdit": {
        "documentChanges": true,
        "resourceOperations": [
          "create",
          "rename",
          "delete"
        ]
      },
      "applyEdit": 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
          ]
        }
      },
      "executeCommand": {
        "dynamicRegistration": false
      },
      "didChangeWatchedFiles": {
        "dynamicRegistration": true
      },
      "workspaceFolders": true,
      "configuration": true,
      "codeLens": {
        "refreshSupport": true
      },
      "fileOperations": {
        "didCreate": false,
        "willCreate": false,
        "didRename": true,
        "willRename": true,
        "didDelete": false,
        "willDelete": false
      }
    },
    "textDocument": {
      "declaration": {
        "dynamicRegistration": true,
        "linkSupport": true
      },
      "definition": {
        "dynamicRegistration": true,
        "linkSupport": true
      },
      "references": {
        "dynamicRegistration": true
      },
      "implementation": {
        "dynamicRegistration": true,
        "linkSupport": true
      },
      "typeDefinition": {
        "dynamicRegistration": true,
        "linkSupport": true
      },
      "synchronization": {
        "willSave": true,
        "didSave": true,
        "willSaveWaitUntil": true
      },
      "documentSymbol": {
        "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
          ]
        },
        "hierarchicalDocumentSymbolSupport": true
      },
      "formatting": {
        "dynamicRegistration": true
      },
      "rangeFormatting": {
        "dynamicRegistration": true
      },
      "onTypeFormatting": {
        "dynamicRegistration": true
      },
      "rename": {
        "dynamicRegistration": true,
        "prepareSupport": true
      },
      "codeAction": {
        "dynamicRegistration": true,
        "isPreferredSupport": true,
        "codeActionLiteralSupport": {
          "codeActionKind": {
            "valueSet": [
              "",
              "quickfix",
              "refactor",
              "refactor.extract",
              "refactor.inline",
              "refactor.rewrite",
              "source",
              "source.organizeImports"
            ]
          }
        },
        "resolveSupport": {
          "properties": [
            "edit",
            "command"
          ]
        },
        "dataSupport": true
      },
      "completion": {
        "completionItem": {
          "snippetSupport": false,
          "documentationFormat": [
            "markdown",
            "plaintext"
          ],
          "resolveAdditionalTextEditsSupport": true,
          "insertReplaceSupport": true,
          "deprecatedSupport": true,
          "resolveSupport": {
            "properties": [
              "documentation",
              "detail",
              "additionalTextEdits",
              "command"
            ]
          },
          "insertTextModeSupport": {
            "valueSet": [
              1,
              2
            ]
          }
        },
        "contextSupport": true,
        "dynamicRegistration": true
      },
      "signatureHelp": {
        "signatureInformation": {
          "parameterInformation": {
            "labelOffsetSupport": true
          }
        },
        "dynamicRegistration": true
      },
      "documentLink": {
        "dynamicRegistration": true,
        "tooltipSupport": true
      },
      "hover": {
        "contentFormat": [
          "markdown",
          "plaintext"
        ],
        "dynamicRegistration": true
      },
      "foldingRange": {
        "dynamicRegistration": true
      },
      "selectionRange": {
        "dynamicRegistration": true
      },
      "callHierarchy": {
        "dynamicRegistration": false
      },
      "typeHierarchy": {
        "dynamicRegistration": true
      },
      "publishDiagnostics": {
        "relatedInformation": true,
        "tagSupport": {
          "valueSet": [
            1,
            2
          ]
        },
        "versionSupport": true
      },
      "linkedEditingRange": {
        "dynamicRegistration": true
      }
    },
    "window": {
      "workDoneProgress": true,
      "showDocument": {
        "support": true
      }
    }
  },
  "initializationOptions": null,
  "workDoneToken": "1"
}

Emacs config

Relevant snippet from my emacs config file

(use-package eglot
  :ensure t
  :commands (eglot eglot-ensure)
  :hook ((rust-mode . eglot-ensure)
         (haskell-mode . eglot-ensure)
         (pyhton-mode . eglot-ensure)))


(use-package lsp-haskell
  :ensure t
  :after (haskell-mode eglot)
  :hook
  (haskell-mode . lsp)
  (haskell-literate-mode . lsp)
  :config
  (setq lsp-haskell-server-path "haskell-language-server-wrapper")
  (setq lsp-haskell-server-args ())
  (setq lsp-log-io t)
  :custom
  (setq lsp-haskell-completion-snippets-on nil))

@michaelpj
Copy link
Collaborator

Yep, this is probably a bug in how we handle that value. Will be fixed like everything else with haskell/lsp#458

@joseedil
Copy link
Author

To update, I was using Mitsuharu's emacs port by compiling it myself.

Using the homebrew pre-compiled binary made it work OK, even though this processId: null is still happening.

@yyoncho
Copy link
Member

yyoncho commented Nov 21, 2022

Using the homebrew pre-compiled binary made it work OK, even though this processId: null is still happening.

It is valid to have null but I just fixed it in lsp-mode.el

@michaelpj
Copy link
Collaborator

Right, so lsp-mode isn't sending null any more, so that won't trigger the bug in HLS. That's good for now, and hopefully we'll fix it up so we accept the valid input later.

@michaelpj
Copy link
Collaborator

Should be fixed in HLS now anyway

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

3 participants