microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.56k stars 266 forks source link

Remote server installation stuck at "Copying VS Code Server to host with scp" #9758

Closed Lablace closed 2 months ago

Lablace commented 3 months ago
[13:33:44.063] > 3a1419d4956b: running
[13:33:44.082] > 3a1419d4956b: pauseLog
[13:33:44.126] > 3a1419d4956b: resumeLog
[13:33:44.798] > Acquiring lock on C:\Users\****\.vscode-server\bin\5c3e652f63e798a5ac2f31ffd0d863669328dc4c\vscode-remote-lock.5c3e652f63e798a5ac2f31ffd0d863669328dc4c
[13:33:44.814] > Looking for existing server in C:\Users\****\.vscode-server\bin\5c3e652f63e798a5ac2f31ffd0d863669328dc4c
> Trigger local server download
> 3a1419d4956b:trigger_server_download
> artifact==server-win32-x64==
> destFolder==C:\Users\****\.vscode-server\bin\==
> destFolder2==/5c3e652f63e798a5ac2f31ffd0d863669328dc4c\vscode-server.zip==
> 3a1419d4956b:trigger_server_download_end
> Waiting for client to transfer server archive...
> Waiting for C:\Users\****\.vscode-server\bin\5c3e652f63e798a5ac2f31ffd0d863669328dc4c\vscode-server.zip.done and vscode-server.zip to exist
[13:33:44.815] Got request to download on client for {"artifact":"server-win32-x64","destPath":"C:\\Users\\****\\.vscode-server\\bin\\/5c3e652f63e798a5ac2f31ffd0d863669328dc4c\\vscode-server.zip"}
[13:33:44.815] Downloading VS Code server locally...
[13:33:44.821] > 
[13:33:52.633] Downloaded VS Code server to /var/folders/****/****/T/4fe7641c-a00e-41e7-968c-b796ed469f8d
[13:33:52.634] Renamed VS Code server to /var/folders/****/****/T/vscode_server_1712640832633/vscode-server.zip
[13:33:52.636] PATH: ****
[13:33:52.636] Checking ssh with "ssh -V"
[13:33:52.642] > OpenSSH_9.6p1, LibreSSL 3.3.6

[13:33:52.643] Testing scp with "scp"
[13:33:52.650] scp exited with code: 1
[13:33:52.650] Got stderr from scp: usage: scp [-346ABCOpqRrsTv] [-c cipher] [-D sftp_server_path] [-F ssh_config]
           [-i identity_file] [-J destination] [-l limit] [-o ssh_option]
           [-P port] [-S program] [-X sftp_option] source ... target
[13:33:52.650] Using SSH config file "****"
[13:33:52.650] Copying file to remote with scp -F '****' 'vscode-server.zip' 'vscode-server.zip.done' 'REMOTE':'C:\Users\****\.vscode-server\bin\'
[13:33:52.651] Using cwd: file:///var/folders/****/****/T/vscode_server_1712640832633
[13:33:53.685] "Copy server to host" terminal received data: "
vscode-server.zip                               0%    0     0.0KB/s   --:-- ETA"
[13:33:54.686] "Copy server to host" terminal received data: "
vscode-server.zip                              22%   11MB  10.7MB/s   00:03 ETA"
[13:33:55.648] "Copy server to host" terminal received data: "
vscode-server.zip                             100%   47MB  24.0MB/s   00:01    "
[13:33:55.726] "Copy server to host" terminal received data: "
vscode-server.zip.done                          0%    0     0.0KB/s   --:-- ETA"
[13:33:55.745] "Copy server to host" terminal received data: "
vscode-server.zip.done                        100%    9     0.5KB/s   00:00    "
[13:33:56.075] "Copy server to host" terminal command done

Steps to Reproduce:

  1. Simply press cmd+shift+P and choose Remote-SSH: Connect Current Window to Host... and select the target Windows Server remote machine.
  2. Visual Studio Code gets stuck with "Copying VS Code Server to host with scp" forever.

How I Tried to Debug

Though the extension is close source, one can manage to view some of its content at ${HOME}/.vscode/extensions/ms-vscode-remote.remote-ssh-0.110.1/out/extension.js, so do I. Take some time and one can find that for Windows platform, it uses the hard-coded powershell script to handle requests. In the logs, lines without time are from the powershell script, others mainly come from the extension itself. And one can find that the script is waiting for file to show up inside ".../bin/${COMMIT_ID}", while scp destination is ".../bin". This is the direct cause. I tried to manually move the two files into the sub-folder and change the destFolder to contain the sub-folder, in both case, the installation can continue and I can have server installed in remote machine successfully.

With some effort I found the problem lies around a generateScpCommand function call, in which the locally downloaded vscode-server is copied to the remote with scp. Specifically, the erroneous call is at the first occurrence, and the definition is at the third. The remote path for vscode-server is stored in destPath argument, and in the function, a call to dirname seems to be the bull's-eye. I then injected some code inside the function body to see whether dirname really does what it names. The injected code is simple: throw new Error("destPath:"+n+"|dirname:"+s);, which simply prints the values of two variables and terminate the installation. I then tried this with the Windows server and another server running Ubuntu, the output is listed below.

remote destPath dirname
Windows C:\Users\****\.vscode-server\bin\/5c3e652f63e798a5ac2f31ffd0d863669328dc4c\vscode-server.zip C:\Users\****\.vscode-server\bin\
Ubuntu /tmp/****/.vscode-server/bin//5c3e652f63e798a5ac2f31ffd0d863669328dc4c/vscode-server.tar.gz /tmp/****/.vscode-server/bin//5c3e652f63e798a5ac2f31ffd0d863669328dc4c

As result tells, on Ubuntu, the dirname does what it names, while on Windows, it removes one more level. This might be the root cause. I also tried using the unmodified extension with the Ubuntu server, and you bet, the server is installed without any problem.

I would like to dive deeper in the body of dirname, but I could not figure out where its definition lies, maybe due to my lack of knowledge in JS, or the obfuscation, thus I have to stop here. Hope this helps.


Does this issue occur when you try this locally?: No Does this issue occur when you try this locally and all extensions are disabled?: No

arghness commented 3 months ago

I'm getting what appears to be the same issue, comparing the log output -- it was working last week, but likely some VSCode related components have updated on the Windows side.

However, I'm connecting from Windows 11 to remote Rocky Linux 8 containers via ssh, using a password protected ssh key (it doesn't ask for the password, as I believe Windows registered it with an ssh agent). I can provide logs or open a separate issue if required.

roblourens commented 3 months ago

Any difference if you set "remote.SSH.useExecServer": false?

arghness commented 3 months ago

Any difference if you set "remote.SSH.useExecServer": false?

That seems to fix it for me, thanks!

It looks like there's a typo on the description for that configuration option by the way -- the description shows "%setting.usseExecServer.description%".

HunterDG commented 3 months ago

Any difference if you set "remote.SSH.useExecServer": false?

This fixed https://github.com/microsoft/vscode-remote-release/issues/9454#issuecomment-2046203046

Any ideas why I still have to manually extract vscode-server.zip? https://github.com/microsoft/vscode-remote-release/issues/9454#issuecomment-1921767241

Lablace commented 3 months ago

Any difference if you set "remote.SSH.useExecServer": false?

This fixed #9454 (comment)

Any ideas why I still have to manually extract vscode-server.zip? #9454 (comment)

Maybe due to the direct cause I stated? The script is waiting for zip files to show up in the bin/${COMMIT_ID} folder while scp and you copied the file to the bin folder?

Lablace commented 3 months ago

Any difference if you set "remote.SSH.useExecServer": false?

remote.SSH.useExecServer is already set to false.

magicus commented 3 months ago

I can add that I got this problem too since upgrading to 1.88.0. Setting remote.SSH.useExecServer to false helped me as well.

But my understanding from e.g. https://github.com/microsoft/vscode-remote-release/issues/8926 is that this was supposed to be a fallback in case of problems. The original problems from #8926 has apparently been fixed, but now some new problem has arisen.

HunterDG commented 3 months ago

Any difference if you set "remote.SSH.useExecServer": false?

This fixed #9454 (comment) Any ideas why I still have to manually extract vscode-server.zip? #9454 (comment)

Maybe due to the direct cause I stated? The script is waiting for zip files to show up in the bin/${COMMIT_ID} folder while scp and you copied the file to the bin folder?

Forgive me, I don't understand the distinction between exec server and vscode server. Seems prior to this issue, Remote SSH copied over vscode server first (which always hung for me), and exec server second (which worked after I manually extracted vscode server and reconnected Remote SSH).

This issue appears to be related to a recent change prioritizing exec server.

My previous attempts (presumably vscode server vs exec server) hangs with a slightly different message: "Copy server to host" terminal command done

I imagine if the same issue existed previously, there would certainly be another issue for it, but I haven't found one thus far, so I figured my problem was environment-specific.

remote.SSH.useExecServer is already set to false.

now that you've mentioned this, it seems you may actually be running in to the same problem I am, but your message is slightly different, and presumably you didn't have this issue prior.

I believe we have 2 (maybe 3) issues at play here. (and I don't have time to dig)

HunterDG commented 3 months ago

EDIT: I've just noticed that the message in the Title of this issue doesn't match the message in your logs.

that, and the fact you already have remote.SSH.useExecServer set to false seems to indicate you are indeed having the exact same issue as me, but I've been having this issue for months - have you?

this also means there are two issues:

Lablace commented 3 months ago

Any difference if you set "remote.SSH.useExecServer": false?

This fixed #9454 (comment) Any ideas why I still have to manually extract vscode-server.zip? #9454 (comment)

Maybe due to the direct cause I stated? The script is waiting for zip files to show up in the bin/${COMMIT_ID} folder while scp and you copied the file to the bin folder?

Forgive me, I don't understand the distinction between exec server and vscode server. Seems prior to this issue, Remote SSH copied over vscode server first (which always hung for me), and exec server second (which worked after I manually extracted vscode server and reconnected Remote SSH).

This issue appears to be related to a recent change prioritizing exec server.

My previous attempts (presumably vscode server vs exec server) fail with a slightly different error message: "Copy server to host" terminal command done

I imagine if the same issue existed previously, there would certainly be another issue for it, but I haven't found one thus far, so I figured my problem was environment-specific.

remote.SSH.useExecServer is already set to false.

now that you've mentioned this, it seems you may actually be running in to the same problem I am, but your error message is slightly different, and presumably you didn't have this issue prior.

I believe we have 2 (maybe 3) issues at play here. (and I don't have time to dig)

You're right at that I didn't have the problem before. The fact is that I used to just use vscode-server on Linux servers, which I also tried this time, and you can see in my analysis that it just worked as before. BUT I have to used a Windows Server now, on which I would like to continue with my previous workflow, that is using vscode-server there rather than using Remote Desktop. And unfortunately it fails to install without manual help (moving the scped archives into the target folder).

To be honest, I also didn't know what an exec server is, but I am used to setting the option to false.

Lablace commented 3 months ago

I believe some problem lies in the dirname function (or related functions) in vscode-server extension, but I really don't have time and effort to investigate the obfuscated code.

Lablace commented 3 months ago

And as a complement, my colleague uses local Windows PC to connect to the same Windows Server as I have connected to without any problem, also he leaves the remote.SSH.useExecServer setting as default.

HunterDG commented 2 months ago

looks like exec server is installed after vscode-server (which still fails on windows remotes, requires manual workaround) with latest release despite remote.SSH.useExecServer set to false

connor4312 commented 2 months ago

I'm not sure this is actually related to the exec server, as the log posted in the original issue is not using the exec server (vscode-server.zip is only used for the non-exec server mode, the exec server uses vscode-cli-$commitId.zip)

I actually only reproduce this with remote.SSH.useExecServer set to false. It works with true. I think others are not experiencing the same issue.

TylerLeonhardt commented 2 months ago

@Lablace @HunterDG can you try using VS Code Insiders and the pre-release version of Remote SSH and let us know if the issue is fixed for you?

connor4312 commented 2 months ago

Steps:

  1. Be on macOS or Linux
  2. Set remote.SSH.useExecServer: false and remote.SSH.localServerDownload: always
  3. SSH to a Windows machine and verify it works
Lablace commented 2 months ago

@Lablace @HunterDG can you try using VS Code Insiders and the pre-release version of Remote SSH and let us know if the issue is fixed for you?

@TylerLeonhardt @connor4312 Sorry for my late reply.

I've used VS Code Insider (Version: 1.89.0-insider (Universal), 2fb3fa8dd2f85d7f452066f8a64e8bf259d21412) with Remote SSH (v0.112.2024042515 (pre-release)) on my local Mac mini (Intel), and could verify that with remote.SSH.localServerDownload set to always and remote.SSH.useExecServer set to false I could successfully have the insider server installed on remote Windows server and remote Ubuntu server.

So my problem is solved, thanks for all your efforts!!!

Lablace commented 2 months ago

I also noticed in the output that the message showing scp details had the right destination now. Previous it was 'REMOTE':'C:\Users\****\.vscode-server' and now it was 'REMOTE':'C:\Users\****\.vscode-server-inside\${COMMIT_ID}'

netjeff commented 2 months ago

FYI: I had similar symptoms. Root cause of my problem is that my .bashrc included output on stdout via an echo command. And scp fails silently if any stdout from .bashrc. And then VS Code not graceful to scp lack of gracefulness. I updated my .bashrc to remove echo to stdout, and then everything works. FYI, I found this comment to be very helpful, https://unix.stackexchange.com/a/257613/9214