Microsoft/vscode

Remote SSH incorrectly strips empty but defined environment variables from shell environment

Open

#168,195 创建于 2022年1月18日

在 GitHub 查看
 (11 评论) (3 反应) (1 负责人)TypeScript (74,848 star) (10,221 fork)batch import
bughelp wantedremoteterminal-process

描述

VSCode Version: 1.63.2 SSH Remote extension latest preview (v0.71.2021121615 Pre-Release) Local OS Version: Fedora 35 Remote OS Version: CentOS 7.9 Remote Extension/Connection Type: SSH

Consider the following setup in your SSH config:

Host slpcomp1-prj
  HostName slpcomp1
  User mkrause
  ForwardX11 yes
  RemoteCommand bash -c "export TESTVAR1=HELLO; export TESTVAR2=HITHERE; export TESTVAR3; bash"

And connect to this node using this config with the SSH Remote Extension with RemoteCommand enabled.

Result: image

TESTVAR3 is incorrectly missing from the environment. This can be a problem if e.g. certain paths prefixes are encoded in such variables and on some machines they are intentionally empty. The behavior does NOT change if TESTVAR3 is defined as an empty string like so export TESTVAR3=""

I think I also understand why: For VS Code itself the variable most probably does exist, but not inside the terminals that are spawned. Reason seems to be the PTY bootstrap script that is launching the Terminal shells:

image

The red arrow shows the actual bash shell in which VS Code is running remotely for the correct environment. The green arrow displays the actual Terminal bash shell embedded inside VS Code. The blue arrow points to the bootstrap Javascript processes which according to what I was able to see somehow post-process the environment and seem to strip those defined but empty variables from the env before the bash is spawned.

This needs to be fixed.

/cc @mhoeher

贡献者指南