Skip to content

Remote clangd JSON parse error #4150

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

Closed
2 of 3 tasks
korteland opened this issue Aug 23, 2023 · 1 comment · Fixed by #4204
Closed
2 of 3 tasks

Remote clangd JSON parse error #4150

korteland opened this issue Aug 23, 2023 · 1 comment · Fixed by #4204
Labels

Comments

@korteland
Copy link

korteland commented Aug 23, 2023

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

When using LSP mode with TRAMP, the remote clangd's status stays as "starting" indefinitely. On the other machine, a file tmp/clangd-remote-1-stderr appears with the following contents:

I[22:51:29.609] Ubuntu clangd version 13.0.1-2ubuntu2.2
I[22:51:29.609] Features: linux+grpc
I[22:51:29.609] PID: 2449947
I[22:51:29.609] Working directory: /home/REDACTED/wiredtiger
I[22:51:29.609] argv[0]: clangd-13
I[22:51:29.609] Starting LSP over stdin/stdout
E[22:51:29.656] JSON parse error: [3:3085, byte=3087]: Expected , or } after object property

Setting lsp-log-io to t per the troubleshooting steps, the content of my *lsp-log: clangd-remote:XXXX* buffer contains the following:

[Trace - 08:53:52 AM] Sending request 'initialize - (1)'.
Params: {
  "processId": null,
  "rootPath": "/home/REDACTED",
  "clientInfo": {
    "name": "emacs",
    "version": "GNU Emacs 29.1 (build 1, aarch64-apple-darwin22.6.0, Carbon Version 169 AppKit 2299.7)\n of 2023-08-06"
  },
  "rootUri": "file:///home/REDACTED",
  "capabilities": {
    "general": {
      "positionEncodings": [
        "utf-32",
        "utf-16"
      ]
    },
    "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"
}



My remote LSP client config is as follows:

(lsp-register-client
 (make-lsp-client :new-connection (lsp-tramp-connection "clangd-13")
                  :major-modes '(c-mode c++-mode c-ts-mode c++-ts-mode)
                  :remote? t
                  :server-id 'clangd-remote))

I believe this is a recent regression - I updated to Emacs 29.1 and updated my lsp-mode package at the same time, so something broke it, but it's hard to say what.

Steps to reproduce

  1. Install EmacsMacApp on macOS
  2. Install lsp-mode, configure for a remote client as per the description
  3. On the machine you're SSHing to, git clone https://github.com/wiredtiger/wiredtiger.git, cd wiredtiger, mkdir build, cd build, cmake -DEXPORT_COMPILE_COMMANDS=ON ../., cp compile_commands.json ..
  4. In Emacs, attempt to open the file /ssh:blah/wiredtiger/src/txn/txn.c
  5. Observe that the clangd state remains "starting".

Expected behavior

I should be able to use LSP-mode, e.g. jumping to definition.

Which Language Server did you use?

clangd-13

OS

MacOS

Error callstack

No response

Anything else?

No response

@korteland korteland added the bug label Aug 23, 2023
yyoncho added a commit to yyoncho/lsp-mode that referenced this issue Oct 27, 2023
- This fixes the implementation of `lsp-mode` tramp support. After this PR the
remote clients will be automatically registered and in most of the cases it will
work out of the box. The remote connection is managed to a way similar to what
eglot does.

Fixes emacs-lsp#4158
Fixes emacs-lsp#4150
Fixes emacs-lsp#4158
Fixes emacs-lsp#4150
Fixes emacs-lsp#3841
Fixes emacs-lsp#3642
Fixes emacs-lsp#3579
Fixes emacs-lsp#3530
Fixes emacs-lsp#3491
Fixes emacs-lsp#3490
Fixes emacs-lsp#3391
Fixes emacs-lsp#3369
Fixes emacs-lsp#3364
Fixes emacs-lsp#3020
Fixes emacs-lsp#3018
Fixes emacs-lsp#3020
yyoncho added a commit to yyoncho/lsp-mode that referenced this issue Oct 30, 2023
- This fixes the implementation of `lsp-mode` tramp support. After this PR the
remote clients will be automatically registered and in most of the cases it will
work out of the box. The remote connection is managed to a way similar to what
eglot does.

Fixes emacs-lsp#4158
Fixes emacs-lsp#4150
Fixes emacs-lsp#4158
Fixes emacs-lsp#4150
Fixes emacs-lsp#3841
Fixes emacs-lsp#3642
Fixes emacs-lsp#3579
Fixes emacs-lsp#3530
Fixes emacs-lsp#3491
Fixes emacs-lsp#3490
Fixes emacs-lsp#3391
Fixes emacs-lsp#3369
Fixes emacs-lsp#3364
Fixes emacs-lsp#3020
Fixes emacs-lsp#3018
Fixes emacs-lsp#3020
yyoncho added a commit that referenced this issue Nov 1, 2023
* Fix lsp-mode's tramp support

- This fixes the implementation of `lsp-mode` tramp support. After this PR the
remote clients will be automatically registered and in most of the cases it will
work out of the box. The remote connection is managed to a way similar to what
eglot does.

Fixes #4158
Fixes #4150
Fixes #4158
Fixes #4150
Fixes #3841
Fixes #3642
Fixes #3579
Fixes #3530
Fixes #3491
Fixes #3490
Fixes #3391
Fixes #3369
Fixes #3364
Fixes #3020
Fixes #3018
Fixes #3020

* Use executable-find with remote = t everywhere
@korteland
Copy link
Author

Thanks @yyoncho ! Very much appreciated.

yyoncho added a commit to yyoncho/lsp-mode that referenced this issue Nov 2, 2023
* Fix lsp-mode's tramp support

- This fixes the implementation of `lsp-mode` tramp support. After this PR the
remote clients will be automatically registered and in most of the cases it will
work out of the box. The remote connection is managed to a way similar to what
eglot does.

Fixes emacs-lsp#4158
Fixes emacs-lsp#4150
Fixes emacs-lsp#4158
Fixes emacs-lsp#4150
Fixes emacs-lsp#3841
Fixes emacs-lsp#3642
Fixes emacs-lsp#3579
Fixes emacs-lsp#3530
Fixes emacs-lsp#3491
Fixes emacs-lsp#3490
Fixes emacs-lsp#3391
Fixes emacs-lsp#3369
Fixes emacs-lsp#3364
Fixes emacs-lsp#3020
Fixes emacs-lsp#3018
Fixes emacs-lsp#3020

* Use executable-find with remote = t everywhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant