clangd / vscode-clangd

Visual Studio Code extension for clangd
https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd
MIT License
641 stars 113 forks source link

Getting 'couldn't create connection to server' after update to v0.1.30 #722

Closed 0v3rt1r3d closed 1 week ago

0v3rt1r3d commented 1 week ago

Today my vscode-clangd plugin had been automatically updated from 0.1.29 to 0.1.30 and I began receiving the following error message for the c++ projects I'm working with (middle-sized c++ project, single directory in the workspace if that matters).

"Clang Language Server client: couldn't create connection to server."

As I can see nothing else changed in my system. Also switching back to 0.1.29 with complete restart of vscode helps (just reloading extensions doesn't).

Logs

[Error - 10:56:29] Clang Language Server client: couldn't create connection to server.
Launching server using command "/opt/homebrew/opt/llvm@18/bin/clangd" failed. Error: spawn "/opt/homebrew/opt/llvm@18/bin/clangd" ENOENT

System information Clangd version (from the log, or clangd --version):

Homebrew clang version 18.1.8
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm@18/bin

clangd extension version: 0.1.30 Operating system: Mac OS Sequoia 15.0

bburgerm commented 1 week ago

I see same issue with "clangd.path": "/usr/bin/clangd" and /usr/bin/clangd --version:

clangd version 17.0.6 (Red Hat 17.0.6-1.module+el8.10.0+20808+e12784c0)
Features: linux
Platform: x86_64-unknown-linux-gnu; target=x86_64-redhat-linux-gnu

On RedHat 8 on Intel CPU as well as

clangd version 18.1.8 (Red Hat 18.1.8-1.module+el8.10.0+22061+3612b2ba)
Features: linux
Platform: aarch64-unknown-linux-gnu; target=aarch64-redhat-linux-gnu

on ARM CPU. Same when only using "clangd.path" : "clangd". Working again after downgrading vscode-clangd to v0.1.29

lingkerio commented 1 week ago

I am experiencing the same issue after the vscode-clangd extension was automatically updated to version 0.1.30. After upgrading, I started seeing the following error when opening my C++ projects.

Reverting back to version 0.1.29 and restarting VSCode resolves the issue. It seems that downgrading is the only workaround currently available.

System details:

HighCommander4 commented 1 week ago

cc @JVApen @quanzhuo

Regression from #708 or #715 I presume?

xinyiZzz commented 1 week ago

I got the same error Error: spawn clangd" ENOENT, It worked fine after rolling back to vscode-clangd v0.1.29.

It seems to be unrelated to the Clangd version, I tried Clangd v13, v16, v17, v18.

HighCommander4 commented 1 week ago

Regression from #708 or #715 I presume?

I posted a patch to revert these changes at https://github.com/clangd/vscode-clangd/pull/724 until we can sort this out.

HighCommander4 commented 1 week ago

The changes suspected of causing this regression have been backed out in 0.1.31. Please give that version a try and let me know if the issue is fixed there.

Carryme1899 commented 1 week ago

Same issue with version 0.1.29 here. Sorry for the mix-up. This issue’s in version 0.1.30.

clangd output:

The flag `-clang-tidy-checks` is obsolete and ignored.
clangd: Unknown command line argument 'bugprone-*,'.  Try: '/usr/bin/clangd --help'
clangd: Unknown command line argument 'misc-*,'.  Try: '/usr/bin/clangd --help'
clangd: Unknown command line argument 'google-*,'.  Try: '/usr/bin/clangd --help'
clangd: Unknown command line argument 'modernize-*,'.  Try: '/usr/bin/clangd --help'
clangd: Unknown command line argument 'readability-*,'.  Try: '/usr/bin/clangd --help'
clangd: Unknown command line argument 'portability-*'.  Try: '/usr/bin/clangd --help'
[Info  - 4:08:33 PM] Connection to server got closed. Server will restart.
[Error - 4:08:33 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 4:08:33 PM] Clang Language Server client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 

Settings in .vscode/settings.json:

"clangd.arguments": [
    "--all-scopes-completion",
    "--background-index",
    "--clang-tidy",
    "--clang-tidy-checks=performance-*, bugprone-*, misc-*, google-*, modernize-*, readability-*, portability-*",
    "--compile-commands-dir=${workspaceFolder}/.vscode",
    "--completion-parse=auto",
    "--completion-style=detailed",
    "--enable-config",
    "--fallback-style=Microsoft",
    "--function-arg-placeholders=true",
    "--header-insertion-decorators",
    "--header-insertion=never",
    "--log=verbose",
    "--pch-storage=memory",
    "--pretty",
    "--ranking-model=decision_forest",
    "-j=8"
],

Removing the --clang-tidy-checks makes everything work as expected.

HighCommander4 commented 1 week ago

@Carryme1899 could you file a new ticket for that please?

lingkerio commented 1 week ago

The changes suspected of causing this regression have been backed out in 0.1.31. Please give that version a try and let me know if the issue is fixed there.

After I updated the version to 0.1.31, this issue disappeared.

JVApen commented 1 week ago

@0v3rt1r3d, @bburgerm, @lingkerio can you share the complete set of settings that are used for clangd? Especially "clangd.arguments"?

bburgerm commented 1 week ago

@JVApen my full configuration is

   "clangd.onConfigChanged": "restart",
   "clangd.arguments": [
      "--header-insertion=never",
      "--pretty",
      "--malloc-trim"
   ],
   "clangd.fallbackFlags": [
      "-std=c++20"
   ],
   "clangd.path": "/usr/bin/clangd"

but I had removed everything with 0.1.30 and had the same issues.

Not with 0.1.31 (or with 0.1.29) all working OK again.

lingkerio commented 1 week ago

@JVApen

  "clangd.arguments": [
    "--all-scopes-completion",
    "--background-index",
    "--clang-tidy",
    "--clang-tidy-checks=performance-*, bugprone-*, misc-*, google-*, modernize-*, readability-*, portability-*",
    "--compile-commands-dir=${workspaceFolder}/.vscode",
    "--completion-parse=auto",
    "--completion-style=detailed",
    "--enable-config",
    "--fallback-style=Webkit",
    "--function-arg-placeholders=true",
    "--header-insertion-decorators",
    "--header-insertion=iwyu",
    "--include-cleaner-stdlib",
    "--log=verbose",
    "--pch-storage=memory",
    "--pretty",
    "--ranking-model=decision_forest",
    "-j=12"
  ],
"clangd.fallbackFlags": [
    "-pedantic",
    "-Wall",
    "-Wextra",
    "-Wcast-align",
    "-Wdouble-promotion",
    "-Wformat=2",
    "-Wimplicit-fallthrough",
    "-Wmisleading-indentation",
    "-Wnon-virtual-dtor",
    "-Wnull-dereference",
    "-Wold-style-cast",
    "-Woverloaded-virtual",
    "-Wpedantic",
    "-Wshadow",
    "-Wunused",
    "-pthread",
    "-fuse-ld=lld",
    "-fsanitize=address",
    "-fsanitize=undefined"
  ],
  "clangd.checkUpdates": false,
  "clangd.onConfigChanged": "restart",
  "clangd.serverCompletionRanking": true,
  "clangd.detectExtensionConflicts": true,
goyalyashpal commented 5 days ago

Today my vscode-clangd plugin had been automatically updated from 0.1.29 to 0.1.30

hi! thanks for such thorough report. i am wondering if in automatically updated, then how did you find the older version you had on your system? are there some logs etc stored by vscode? thanks.

JVApen commented 4 days ago

Configuration of @lingkerio can be explained with the spaces in the clang-tidy checks, similar to #725 However, the configuration of @bburgerm does not seem to have any spaces or double quotes in them. Neither in the arguments or the program.

I'm wondering what could cause the issue. Can it be these programs are symlinks? I'll test that later today