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.66k stars 286 forks source link

Support wget-snap in install scripts #6418

Closed amaury-ml closed 1 year ago

amaury-ml commented 2 years ago

Here is the trace I have when I try to remote ssh in VS code from a win10 system:

[11:01:29.955] Log Level: 2
[11:01:29.957] remote-ssh@0.76.1
[11:01:29.957] win32 x64
[11:01:29.972] SSH Resolver called for "ssh-remote+rpi", attempt 1
[11:01:29.973] "remote.SSH.useLocalServer": false
[11:01:29.973] "remote.SSH.showLoginTerminal": false
[11:01:29.974] "remote.SSH.remotePlatform": {"rpi":"linux"}
[11:01:29.974] "remote.SSH.path": undefined
[11:01:29.974] "remote.SSH.configFile": undefined
[11:01:29.975] "remote.SSH.useFlock": true
[11:01:29.975] "remote.SSH.lockfilesInTmp": false
[11:01:29.975] "remote.SSH.localServerDownload": auto
[11:01:29.975] "remote.SSH.remoteServerListenOnSocket": false
[11:01:29.975] "remote.SSH.showLoginTerminal": false
[11:01:29.975] "remote.SSH.defaultExtensions": []
[11:01:29.975] "remote.SSH.loglevel": 2
[11:01:29.975] "remote.SSH.maxReconnectionAttempts": 2
[11:01:29.975] "remote.SSH.enableDynamicForwarding": true
[11:01:29.976] "remote.SSH.enableRemoteCommand": false
[11:01:29.976] "remote.SSH.serverPickPortsFromRange": {}
[11:01:29.976] "remote.SSH.serverInstallPath": {}
[11:01:30.008] SSH Resolver called for host: rpi
[11:01:30.008] Setting up SSH remote "rpi"
[11:01:30.034] Using commit id "b5205cc8eb4fbaa726835538cd82372cc0222d43" and quality "stable" for server
[11:01:30.043] Install and start server if needed
[11:01:30.047] Checking ssh with "ssh -V"
[11:01:30.174] > OpenSSH_for_Windows
[11:01:30.175] > _8.1p1, LibreSSL 3.0.2

[11:01:30.187] Running script with connection command: ssh -T -D 56318 rpi bash
[11:01:30.194] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[11:01:30.560] > ]0;C:\WINDOWS\System32\cmd.exe
[11:01:30.561] Got some output, clearing connection timeout
[11:01:30.915] > 29f727553e1a: running
[11:01:31.035] > Acquiring lock on /home/XxRemoteUserxX/.vscode-server/bin/b5205cc8eb4fbaa726835538cd
> 82372cc0222d43/vscode-remote-lock.XxRemoteUserxX.b5205cc8eb4fbaa726835538cd82372cc02
> 22d43
[11:01:31.083] > Found existing installation at /home/XxRemoteUserxX/.vscode-server/bin/b5205cc8eb4fb
> aa726835538cd82372cc0222d43...
[11:01:31.094] > Checking /home/XxRemoteUserxX/.vscode-server/.b5205cc8eb4fbaa726835538cd82372cc0222d
> 43.log and /home/XxRemoteUserxX/.vscode-server/.b5205cc8eb4fbaa726835538cd82372cc022
> 2d43.pid for a running server
[11:01:31.108] > Looking for server with pid: 38305
[11:01:31.161] > Found running server...
[11:01:31.181] > 
> *
> * Reminder: You may only use this software with Visual Studio family products, 
> * as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)
> *
> 
[11:01:31.213] > Neither wget nor curl is installed
> 29f727553e1a: start
> exitCode==26==
> listeningOn==40531==      
> osReleaseId==ubuntu-core==
> arch==aarch64==
> tmpDir==/run/user/1000==  
> platform==linux==
> unpackResult====
> didLocalDownload==0==     
> downloadTime====
> installTime====
> extInstallTime====        
> serverStartTime====
> 29f727553e1a: end
[11:01:31.213] Received install output: 
exitCode==26==
listeningOn==40531==      
osReleaseId==ubuntu-core==
arch==aarch64==
tmpDir==/run/user/1000==  
platform==linux==
unpackResult====
didLocalDownload==0==     
downloadTime====
installTime====
extInstallTime====        
serverStartTime====

[11:01:31.214] Neither curl nor wget is installed - can't download the Server
[11:01:31.215] Resolver error: Error: Downloading VS Code Server failed - please install either curl or wget on the remote.
    at Function.ServerInstallError (c:\Users\XxWin10UserxX\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:585975)
    at p (c:\Users\XxWin10UserxX\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:578818)
    at Object.t.handleInstallOutput (c:\Users\XxWin10UserxX\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:583109)
    at Object.t.tryInstall (c:\Users\XxWin10UserxX\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:681846)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async c:\Users\XxWin10UserxX\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:644486
    at async Object.t.withShowDetailsEvent (c:\Users\XxWin10UserxX\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:647831)
    at async Object.t.resolve (c:\Users\XxWin10UserxX\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:645565)
    at async c:\Users\XxWin10UserxX\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:722872
[11:01:31.225] ------

[11:01:31.786] > 
[11:01:33.091] "install" terminal command done
[11:01:33.091] Install terminal quit with output: 
[11:01:58.795] Picking SSH host
[11:02:01.821] Selected rpi

As far as I know it used to work fine and I cannot remember if there was an update or something in the last 2 to 3 days, but it simply stopped working. The remote system is an Ubuntu Core running ubuntu 18.04 in a container. Nothing that different from a user standpoint. And yes, wget is intalled:

(classic)XxRemoteUserxX@rpi:~$ which wget /usr/bin/wget (classic)XxRemoteUserxX@rpi:~$ dpkg -l | grep -w wget ii wget 1.19.4-1ubuntu2.2 arm64 retrieves files from the web

And a simple ssh into the linux host goes straight to a 'sudo classic' to jump to the container.

Now, if I go and remove ~/.vscode-server, it will reinstall, via scp from the win10 host (sorry, no debug trace, as it's not visible, and succeeds, so it disappears), and it works... until I go open a folder, and then it VS code tries to reinstall the server for some reason and that when it complains.

amaury-ml commented 2 years ago

Looks like it happens because vscode launches another server instance of the already running server. I'd recommend either 1- Allow the client attach to the currently running server 2- Kill the server when the # of clients drops to 0.

Anyway, it doesn't look like I'll see a fix soon, as I've seen no update on this one in 2 weeks The workaround is to kill all processes that relate to vscode-server every time a connection happen (when you change folder, or reconnect)

bamurtaugh commented 2 years ago

cc @tanhakabir

tanhakabir commented 2 years ago

Hm it looks like we aren't able to resolve wget or curl in your container. Are you able to run wget --version or curl --version in your remote container? We run these commands to verify you have wget or curl available.

amaury-ml commented 2 years ago

Sorry for not getting back to you... Yes, wget is present (see my original post), though I don't really know if the --version is available (though it should, I don't see why not). And I would LOVE to be able to tell you for sure, unfortunately my RPI was snatched from my desk and I won't get a new one any time soon (none are available for a reasonable price from a reasonable provider).

tanhakabir commented 2 years ago

Ah that's unfortunate! Are you able to get one back in the future?

amaury-ml commented 2 years ago

I really hope so. Those lil' buggers are a lot easier to use than most of the arm embedded systems I have to work on...

amaury-ml commented 2 years ago

Hey there, got my device back online, and here's what I have for wget (curl is not installed)


(classic)XxRemoteUserxX@borabora:~$ wget --version
GNU Wget 1.19.4 built on linux-gnu.

-cares +digest -gpgme +https +ipv6 +iri +large-file -metalink +nls
+ntlm +opie +psl +ssl/openssl

Wgetrc:
    /etc/wgetrc (system)
Locale:
    /usr/share/locale
Compile:
    gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/etc/wgetrc"
    -DLOCALEDIR="/usr/share/locale" -I. -I../../src -I../lib
    -I../../lib -Wdate-time -D_FORTIFY_SOURCE=2 -DHAVE_LIBSSL -DNDEBUG
    -g -O2 -fdebug-prefix-map=/build/wget-ofwQt7/wget-1.19.4=.
    -fstack-protector-strong -Wformat -Werror=format-security
    -DNO_SSLv2 -D_FILE_OFFSET_BITS=64 -g -Wall
Link:
    gcc -DHAVE_LIBSSL -DNDEBUG -g -O2
    -fdebug-prefix-map=/build/wget-ofwQt7/wget-1.19.4=.
    -fstack-protector-strong -Wformat -Werror=format-security
    -DNO_SSLv2 -D_FILE_OFFSET_BITS=64 -g -Wall -Wl,-Bsymbolic-functions
    -Wl,-z,relro -Wl,-z,now -lpcre -luuid -lidn2 -lssl -lcrypto -lpsl
    ftp-opie.o openssl.o http-ntlm.o ../lib/libgnu.a

Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://www.gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Originally written by Hrvoje Niksic <hniksic@xemacs.org>.
Please send bug reports and questions to <bug-wget@gnu.org>.

Also, FYI, ubuntu core is very limited, and one has to run sudo classic to get to the usual environment (bash + ubuntu installer apt + ...) But my .bashrc does exactly that for me (so I'm always in the classic mode).

[ -z $debian_chroot ] && sudo classic || echo "'sudo classic' or 'sudo SUDO_USER=root classic' to install something... Good to go!"

And if it was missed the 1st time, the whole thing works fine until a change of folder or a disconnect/reconnect happen and it needs to connect to the running vscode server. Though the 1st install happen via an scp (not wget but it could be due to my network config)

amaury-ml commented 2 years ago

I just noticed that you may not use ssh user@blah (or you may specify the shell to use) when setting up things (though not the 1st time) and the sudo classic may not be executed at all. In that case, wget does not exist (if I remove the line from by bahrc that does sudo classic, wget is not available, but I do have a wget-snap available. Yeah, I know... still learning ubuntu core myself and how to use containers...

tanhakabir commented 2 years ago

Hm I see. I'm also not super familiar with Ubuntu Core. Are you able to run the following?

echo "wget --version" | ssh -T -D 56318 rpi bash 
amaury-ml commented 2 years ago

Nope, and that's the problem I guess

$ ssh rpi "wget --version"
bash: wget: command not found

$ ssh rpi "wget-snap --version"
GNU Wget 1.20.3 built on linux-gnu.
tanhakabir commented 2 years ago

Yeah that seems like the issue. Your environment on initial connection doesn't seem to have wget so our script fails. I can investigate if we can use wget-snap as well

amaury-ml commented 2 years ago

Or make the tool be settable by the user (wget or curl or.... ), and its path.

roblourens commented 1 year ago

Now it should also fall back to download locally