Skip to content
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

Visual Studio Code Remote: errors on connect #722

Closed
serl opened this issue Apr 13, 2024 · 4 comments · Fixed by #725
Closed

Visual Studio Code Remote: errors on connect #722

serl opened this issue Apr 13, 2024 · 4 comments · Fixed by #725

Comments

@serl
Copy link
Contributor

serl commented Apr 13, 2024

Problem/Motivation

I used to connect Visual Studio Code to this add-on, but it stopped working recently. I tried to remove the .vscode-server in the remote machine, it didn't help.
My guess is that's an update on Visual Studio side, so I guess I'll open a ticket there.

Am I alone in this?

Expected behavior

Use the Remote-SSH extension to connect to my Home Assistant and edit config.

Actual behavior

Gives an error, here's the log:

[15:42:54.432] Opening exec server for ssh-remote+xxx
[15:42:54.435] Acquiring local install lock: /var/folders/q8/1234/T/vscode-remote-ssh-013e253e-install.lock
[15:42:54.435] Initizing new exec server for ssh-remote+xxx
[15:42:54.448] Looking for existing server data file at /Users/yyy/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-013e253e-e170252f762678dec6ca2cc69aba1570769a5d39-0.110.1-es/data.json
[15:42:54.455] Using commit id "e170252f762678dec6ca2cc69aba1570769a5d39" and quality "stable" for server
[15:42:54.456] Install and start server if needed
[15:42:54.462] askpass server listening on /var/folders/q8/1234/T/vscode-ssh-askpass-zzz.sock
[15:42:54.462] Spawning local server with {"serverId":2,"ipcHandlePath":"/var/folders/q8/1234/T/vscode-ssh-askpass-48e7611b018e77b72d2ce75ea8a69076de069fe0.sock","sshCommand":"ssh","sshArgs":["-v","-T","-D","50650","-o","ConnectTimeout=15","xxx"],"serverDataFolderName":".vscode-server","dataFilePath":"/Users/yyy/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-013e253e-e170252f762678dec6ca2cc69aba1570769a5d39-0.110.1-es/data.json"}
[15:42:54.462] Local server env: {"SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.1234567890/Listeners","SHELL":"/opt/homebrew/bin/bash","DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"/Users/yyy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.110.1/out/local-server/askpass.sh","VSCODE_SSH_ASKPASS_NODE":"/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin)","VSCODE_SSH_ASKPASS_EXTRA_ARGS":"","VSCODE_SSH_ASKPASS_MAIN":"/Users/yyy/.vscode/extensions/ms-vscode-remote.remote-ssh-0.110.1/out/askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"/var/folders/q8/1234/T/vscode-ssh-askpass-zzz.sock"}
[15:42:54.463] Spawned 49743
[15:42:54.549] > local-server-2> Running ssh connection command: ssh -v -T -D 50650 -o ConnectTimeout=15 xxx
[15:42:54.552] > local-server-2> Spawned ssh, pid=49755
[15:42:54.555] stderr> OpenSSH_9.6p1, LibreSSL 3.3.6
[15:42:54.577] > 
>        ▄██▄           _   _                                    
>      ▄██████▄        | | | | ___  _ __ ___   ___               
>    ▄████▀▀████▄      | |_| |/ _ \| '_ ` _ \ / _ \              
>  ▄█████    █████▄    |  _  | (_) | | | | | |  __/              
> ▄██████▄  ▄██████▄   |_| |_|\___/|_| |_| |_|\___|          _   
> ████████  ██▀  ▀██      / \   ___ ___(_)___| |_ __ _ _ __ | |_ 
> ███▀▀███  ██   ▄██     / _ \ / __/ __| / __| __/ _` | '_ \| __|
> ██    ██  ▀ ▄█████    / ___ \\__ \__ \ \__ \ || (_| | | | | |_ 
> ███▄▄ ▀█  ▄███████   /_/   \_\___/___/_|___/\__\__,_|_| |_|\__|
> ▀█████▄   ███████▀
> 
> Welcome to the Home Assistant command line.
[15:42:54.581] > System information
[15:42:54.582] >   IPv4 addresses for end0:  192.168.0.2/24
>   IPv6 addresses for end0: 
>   IPv4 addresses for wlan0: 
[15:42:54.585] >   OS Version:               Home Assistant OS 12.1
>   Home Assistant Core:      2024.4.2
> 
>   Home Assistant URL:       http://homeassistant.local:8123
>   Observer URL:             http://homeassistant.local:4357
[15:42:54.586] > ready: e526734718b1
[15:42:54.592] > Linux 6.1.73-haos-raspi #1 SMP PREEMPT Wed Mar 13 12:11:05 UTC 2024
[15:42:54.592] Platform: linux
[15:42:54.596] > /bin/zsh
[15:42:54.597] Shell: zsh
[15:42:54.597] Creating bash subshell inside "zsh"
[15:42:54.603] > bash version:  5.2.21(1)-release
[15:42:54.615] > e526734718b1: running
[15:42:54.628] > Found existing installation at /root/.vscode-server...
> Starting VS Code CLI... "/root/.vscode-server/code-e170252f762678dec6ca2cc69aba1570769a5d39" command-shell --cli-data-dir "/root/.vscode-server/cli" --on-port --parent-process-id 3033 &> "/root/.vscode-server/.cli.e170252f762678dec6ca2cc69aba1570769a5d39.log" < /dev/null
> printenv:
>     SHELL=/bin/zsh
>     SUDO_GID=1000
>     CHARSET=UTF-8
>     SUDO_COMMAND=/bin/zsh
>     SUDO_USER=xxx
>     PWD=/root
>     LOGNAME=root
>     TZ=Europe/Paris
>     HOME=/root
>     LANG=en_US.UTF-8
>     VSCODE_AGENT_FOLDER=/root/.vscode-server
>     TERM=unknown
>     USER=root
>     SUPERVISOR_TOKEN=--redacted--
>     SHLVL=2
>     PAGER=less
>     LC_COLLATE=C
>     PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
>     SUDO_UID=1000
>     MAIL=/var/mail/root
>     OLDPWD=/root
>     _=/bin/printenv
> Removing old logfile at /root/.vscode-server/.cli.e170252f762678dec6ca2cc69aba1570769a5d39.log
> Spawned remote CLI: 3053
[15:42:54.630] stderr> ps: unrecognized option: p
[15:42:54.632] > Exec server process not found
[15:42:54.632] stderr> BusyBox v1.36.1 (2023-11-07 18:53:09 UTC) multi-call binary.
[15:42:54.632] stderr> 
[15:42:54.632] stderr> Usage: ps [-o COL1,COL2=HEADER] [-T]
[15:42:54.633] stderr> 
[15:42:54.633] stderr> Show list of processes
[15:42:54.633] stderr> 
[15:42:54.633] stderr> 	-o COL1,COL2=HEADER	Select columns for display
[15:42:54.633] stderr> 	-T			Show threads
[15:42:54.635] > e526734718b1: start
> SSH_AUTH_SOCK====
> DISPLAY====
> listeningOn====
> osReleaseId==alpine==
> arch==aarch64==
> vscodeArch==arm64==
> bitness==64==
> tmpDir==/tmp==
> platform==linux==
> unpackResult====
> didLocalDownload==0==
> downloadTime====
> installTime====
> serverStartTime==0==
> execServerToken==1a1a1111-111a-1a1a-11a1-1aa11a1a11a1==
> e526734718b1: end
[15:42:54.635] Received install output: 
SSH_AUTH_SOCK====
DISPLAY====
listeningOn====
osReleaseId==alpine==
arch==aarch64==
vscodeArch==arm64==
bitness==64==
tmpDir==/tmp==
platform==linux==
unpackResult====
didLocalDownload==0==
downloadTime====
installTime====
serverStartTime==0==
execServerToken==1a1a1111-111a-1a1a-11a1-1aa11a1a11a1==

[15:42:54.635] Failed to parse remote port from server output
[15:42:54.636] Terminating local server
[15:42:54.637] Exec server for ssh-remote+xxx failed: Error
[15:42:54.637] Error opening exec server for ssh-remote+xxx: Error
[15:42:54.641] Local server exit: 15

It seems like VSCode is calling ps with a little too many parameters.

I found an old ticket on their side, which contains this line:

Remote-Containers reads /proc to avoid the need for ps which isn't necessarily installed

Steps to reproduce

  • Install this addon and the SSH Remote extension in VSCode
  • Add the relevant configuration for VS Code
  • Make sure you can connect using ssh from the command line
  • Try to connect to the machine using VS Code

🙏 thanks for your attention

@ross-kleiman
Copy link

ross-kleiman commented Apr 13, 2024

I was able to resolve this error and I can connect successfully via VSCode SSH. It appears the issue is that the Alpine Linux distro uses a more limited version of ps that does not accept the -p flag. by adding 'procps' to the 'apks' section of the addon's config file I was able to add the full featured ps command and this in turn resolved the error. I can successfully connect to my HA instance and edit code remotely. Hope this helps you @serl

Here is a helpful discussion of this on nixCraft: https://www.nixcraft.com/t/how-to-install-real-ps-command-on-alpine-linux/4351

@serl
Copy link
Contributor Author

serl commented Apr 14, 2024

That is fantastic, it worked like a charm, thanks a lot!

I opened a pull request to add this to the readme, just in case others fall in the same trap

@kinghat
Copy link

kinghat commented Apr 29, 2024

@serl do you know when an update for this addon will be cut?

@frenck
Copy link
Member

frenck commented Apr 29, 2024

@kinghat He doesn't.

It will be cut when I have spare time and when it has been tested on multiple setups on different architectures.

../Frenck

@github-actions github-actions bot locked and limited conversation to collaborators May 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants