vscode-clangd icon indicating copy to clipboard operation
vscode-clangd copied to clipboard

remote: autoinstall writes `clangd.path` to the local user config, rather than the remote machine config

Open yanggehua opened this issue 5 years ago • 14 comments

VSCode Version: Version: 1.46.0-insider (user setup)
Commit: 288852d
Date: 2020-05-12T05:43:31.363Z
Electron: 7.2.4
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363

OS Version: Windows 10

Steps to Reproduce:

Open VS Code insider
Got notification "The Clangd language server was not found on your PATH. Would you like to download and install clangd 10.0.0". Source: clangd (extension). The only choice is INSTALL button (see screen shot)
Click INSTALL. The installation completed without any issue.
Click Reload Window. VS Code insider restarts, but got the same notification in Step 2. Click INSTALL will go back to step 3.

Meanwhile, clangd extension stopps working. It was fully functional yesterday. Screenshots with REMOTE and WORKSPACE Clangd settings.

VS-clangd-workspace VS-clangd-remote

yanggehua avatar May 12 '20 14:05 yanggehua

Just verified clangd extension does not work locally on a Ubuntu 18.04 computer either.

yanggehua avatar May 12 '20 14:05 yanggehua

Ah, I think we hadn't properly considered the interaction with remote :-( I tried this out, and what I saw was:

  • I got the prompt based on whether the clangd.path binary existed remotely, OK
  • the binary was downloaded onto the remote host
  • but the clangd.path was written to the local user settings

The issue with your path being tools/clangd seems like #22 - that did indeed work sometimes by accident and doesn't now. However it's not clear what that should do, I think ${workspaceRoot}/tools/clangd would be clearer and will be supported very soon now.

sam-mccall avatar May 12 '20 15:05 sam-mccall

Yes, the issue is very similar with #22 . We can close this one as duplicate.

yanggehua avatar May 12 '20 17:05 yanggehua

Actually there's two issues here.

One is indeed a dupe of #22 (tools/clangd is no longer resolved relative to workspace root) which is now fixed.

The other issue that after installing clangd we write clangd.path to the user config (local ~/.config/Code/settings.json) rather than the machine config (remote ~/.vscode-server/data/Machine/settings.json). This has two problems:

  • if you already have a clangd.path in your remote workspace config, then it will take precedence over the local user one. This is why even after installing clangd through the wizard, it didn't work for you.
  • setting clangd.path in your local config, to a path that isn't present on the local machine, means that local clangd won't work.

I'd like to keep this open for the second issue.

sam-mccall avatar May 12 '20 18:05 sam-mccall

Confirmed that this is fixed in v0.1.7.

hokein avatar Sep 07 '20 12:09 hokein

Looks like it is not fixed in v0.1.7, but broken. Until this version, all steps from this issue were working ok, clangd was installed on remote and clangd.path was updated correctly. But after update same steps lead me to same wrong result: clangd.path is written to local settings (/Users/noxwell/Library/Application Support/Code/User/settings.json) and clangd on remote not work. Remote and workspace settings are empty. I even tried to remove clangd.path from local setting by hand, but autoinstall still writes it here.

Version: 1.49.0
Commit: e790b931385d72cf5669fcefc51cdf65990efa5d
Date: 2020-09-10T17:39:53.251Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 19.6.0

noxwell avatar Sep 15 '20 14:09 noxwell

@noxwell could you provide more details on reproducing the issue?

I didn't reproduce the issue with the following steps:

  • open vscode
  • connected to the remote machine
  • open a c++ file on remote machine (my User/Remote/Workspace clangd setting are empty)
  • install dialog is prompted up, and click install
  • the clangd path is set in remote setting (~/.vscode-server/data/Machine/settings.json)

hokein avatar Sep 16 '20 11:09 hokein

@hokein I am also seeing this issue. Host computer: MAC, clangd not installed Remote computer: Linux - RHEL 7, clangd is installed

  • open vscode on MAC
  • connected to the remote machine
  • open a c++ file on remote machine (my setting.json has "clangd.path" configured)
  • install dialog is prompted up (even though it shouldn't because it is already installed an in my $PATH)
  • click install
  • the clangd path is set in LOCAL host setting (/Users//Library/Application\ Support/Code/User/settings.json)
cat /Users/<user>/Library/Application\ Support/Code/User/settings.json
{
    "files.autoSave": "afterDelay",
    "C_Cpp.updateChannel": "Insiders",
    "cmake.configureOnOpen": true,
    "clangd.path": "/home/<user>/.vscode-server/data/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/10.0.0/clangd_10.0.0/bin/clangd",
}%

  • Nothing written to remote machine.
  • Loop occurs on reload (install dialog is prompted up.... )
  • clangd not working on remote machine...

KCSesh avatar Sep 23 '20 21:09 KCSesh

After trying a few combinations, I think I managed to reproduce partially -- it seems only occur when clangd is not installed in remote machine (which clangd reports clangd not found) and there is no "clangd.argument" config in remote setting.json.

Reproduce steps:

  1. make sure there is no clangd.path config in all setting.json (user setting: /Users/<user>/Library/Application Support/Code/User/settings.json, remote setting: /usr/local/home/<user>/.vscode-server/data/Machine/settings.json), and there is no clangd installed in the remote machine

  2. open vscode and connected to remote machine

  3. open a new /tmp/t.cpp file

  4. install dialog is prompted up, and choose to install clangd

  5. clangd path is set in user setting (/Users/<user>/Library/Application Support/Code/User/settings.json)

Interestingly, if we add "clangd.path": "" in remote setting.json, then the clangd.path is set correctly in the remote setting.json -- it seems to me this is a bug in VSCode's WorkspaceConfiguation.update API, it should always update the clangd.path in remote setting.json regardless whether there is clangd.path or not.

A temporary workaround is to set "clangd.path": "clangd" in remote setting.json.

However, I could not reproduce the same issue mentioned by @KCSesh.

(my setting.json has "clangd.path" configured)

which setting.json and what's the value of clangd.path? there are three different setting.jsons

  • User setting, the one in host machine, e.g. /Users/<user>/Library/Application Support/Code/User/settings.json
  • Remote setting, the one in remote machine, e.g. /usr/local/home/<user>/.vscode-server/data/Machine/settings.json
  • (Possible if you open a folder in VSCode) Workspace setting, also in remote machine, e.g. /usr/local/home/<user>/workspace/llvm-project/.vscode/settings.json

install dialog is prompted up (even though it shouldn't because it is already installed an in my $PATH)

yeah, this should not be happened -- as you have installed clangd in the remote machine, could you verify the command which clangd work in your terminal? could you paste the message shown in the install diaglog, something like The 'clangd' language server was not found on your PATH?

hokein avatar Sep 25 '20 12:09 hokein

I had the same problem.

As @hokein suggested, setting "clangd.path": "clangd" in remote setting.json (not in settings editior, nor in the local settings.json!) manually then press "install" in the prompt solved the issue. For what's worth, the clangd.path will automatically changed to the installation path after that, like "clangd.path": "/home/kbumsik/.vscode-server/data/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/10.0.0/clangd_10.0.0/bin/clangd"

kbumsik avatar Oct 21 '20 09:10 kbumsik

Confirm still having the same problem.

lizhanhui avatar Jan 23 '21 04:01 lizhanhui

Confirm still having the same problem.

The same.

dshelem avatar Jan 26 '21 08:01 dshelem

Confirm still having the same problem.

Issue still the same: Version 1.52.1 (stable release channel)

ostanislaw avatar Jan 26 '21 14:01 ostanislaw

i'm seeing the same thing. inoperable on remote connection.

my user settings .json is on windows, but it contains a linux path on my remote machine.

Spongman avatar Feb 10 '21 00:02 Spongman