Remote SSH incorrectly strips empty but defined environment variables from shell environment
See original GitHub issueVSCode 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:
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:
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
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:11 (6 by maintainers)
Top GitHub Comments
In the OP, it sounds like @markusdd has identified that the variables are removed by the ptyHost
please reopen this is not solved.