-
Notifications
You must be signed in to change notification settings - Fork 385
VSCode terminal broken when using Remote WSL extension and scripts from this repo #33
Comments
Actually it turns out that removing the On closer inspection it's once again due to bad escaping (single quotes this time). Running the following with VSCode attached to my WSL instance
Gives me the following output (irrelevant ENV vars have been removed for clarity):
|
Can you try changing the command to the following to see if it fixes things? I've done a quick test with this change for sanity and it seems to work for me with the change. (the else
exec /usr/bin/nsenter -t "$SYSTEMD_PID" -a /bin/login -p -f "$SUDO_USER"
fi The terminal inside vscode when using this change starts in the wrong folder, but I can work on that tomorrow once we confirm that your use-case is improved by the fix here. |
I haven't tried that yet, but replacing the final if [ -n "$SYSTEMD_PID" ] && [ "$SYSTEMD_PID" != "1" ]; then
if [ -n "$1" ] && [ "$1" != "bash --login" ] && [ "$1" != "/bin/bash --login" ]; then
exec /usr/bin/nsenter -t "$SYSTEMD_PID" -a \
/usr/bin/sudo -H -u "$SUDO_USER" \
/bin/bash -c 'set -a; [ -f "$HOME/.systemd-env" ] && source "$HOME/.systemd-env"; set +a; exec bash -c '"$(printf "%q" "$@")"
else
exec /usr/bin/nsenter -t "$SYSTEMD_PID" -a \
bash -c '/bin/login -p -f "$SUDO_USER" $([ -f "$USER_HOME/.systemd-env" ] && /bin/cat "$USER_HOME/.systemd-env" | xargs -d '\''\n'\'')'
fi
echo "Existential crisis"
exit 1
fi |
Yeah, your fix works as well (and puts me in the correct directory), so I assume that'll do it. |
* VSCode WSL-remote fails: issue DamionGans#33 * `/bin/login` does not support environment variable setting via the command line when used with the `-f` flag that allows login to operate without requesting a password. Signed-off-by: Daniel Llewellyn <[email protected]>
Problem solved. Thanks for your help! |
Thank you for this! |
I use this to replace the else block, it works on VSCode but it seems that won't bring you to the project directory, but at least, it works: exec /usr/bin/nsenter -t "$SYSTEMD_PID" -a \
/bin/bash -c 'set -a; [ -f '"$USER_HOME/.systemd-env"' ] && source '"$USER_HOME/.systemd-env"'; set +a; exec /bin/login -p -f '"$SUDO_USER" EDIT: assign PRE_NAMESPACE_PWD to PWD inside .systemd-env works to enter correct directory: exec /usr/bin/nsenter -t "$SYSTEMD_PID" -a \
/bin/bash -c 'set -a; [ -f '"$USER_HOME/.systemd-env"' ] && source '"$USER_HOME/.systemd-env"'; export PRE_NAMESPACE_PWD="$PWD"; set +a; exec /bin/login -p -f '"$SUDO_USER" |
Bash not crashing anymore which is great but the current directory is still not correct. |
I have the same issue as tomershukhman. |
* VSCode WSL-remote fails: issue DamionGans#33 * `/bin/login` does not support environment variable setting via the command line when used with the `-f` flag that allows login to operate without requesting a password. Signed-off-by: Daniel Llewellyn <[email protected]> Signed-off-by: Sung Mingi <[email protected]>
* VSCode WSL-remote fails: issue DamionGans#33 * `/bin/login` does not support environment variable setting via the command line when used with the `-f` flag that allows login to operate without requesting a password. Signed-off-by: Daniel Llewellyn <[email protected]> Signed-off-by: Sung Mingi <[email protected]>
* VSCode WSL-remote fails: issue DamionGans#33 * `/bin/login` does not support environment variable setting via the command line when used with the `-f` flag that allows login to operate without requesting a password. Signed-off-by: Daniel Llewellyn <[email protected]> Signed-off-by: Sung Mingi <[email protected]>
This was originally reported at, microsoft/vscode#102628, however I believe that the issue at play is in the scripts used here, not in VSCode.
Observed problem
When running VSCode's Remote WSL extension with this script in place on the most recent Windows Insider build (20175.1000), the terminal fails to start. It flashes the following errors briefly before closing.
Underlying problems
The output above points to two separate issues:
xargs
is choking because of bad quoting somewhere, andlogin
command is being run with arguments that it doesn't expect.Xargs issue
The
xargs
error above comes from the usage of thexargs
command at line 47 ofenter-systemd-namespace
.When the WSL Remote extension connects, it creates/modifies
~/.systemd-env
. The line below is from that file. When I delete only this line and run the command manually, thexargs
error goes away.Fix
I couldn't make sense of that mess of escape sequences, so I simply edited
enter-systemd-namespace
to use\n
as a delimiter by replacingxargs printf ' %q'
withxargs -d '\n' printf ' %q'
at line 47 ofenter-systemd-namespace
. This appears to make things work as expected.Login command issue
Regardless of whether the
xargs
fix above is in place, the VSCode terminal shows the following error immediately prior to exiting.With the
xargs
fix in place, thelogin
command that's failing now looks like the following on my machineUnfortunately I don't yet have a fix for this one. I assume the failure is either because of the single quotes causing the double quotes to be passed as part of the env var args, or because
login
doesn't expect a list of env vars when the-f
flag is used, as shown at the top of thelogin
man page, which I've included below:The text was updated successfully, but these errors were encountered: