-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
Empty environment variables passed to vs code are unset #174330
Comments
I'm seeing the variable make it to the debugger, eg here in the debug console, it's in But I'm not seeing it in the terminal. @Tyriar @meganrogge does one of the terminal processes clear out variables with empty values? |
yep, looks like that would happen here
|
To give some more context on how I was experiencing the issue primarily: it was when running tests or the debugger (with the Go extension installed). Is it possible a similar (or maybe the same) behaviour to is affecting how env vars get passed down to extensions (as well as the terminal process)? |
Maybe if the debuggee is launched from a terminal? Or something particular to that debug extension. It worked for me when debugging node. |
I did think it could be one of those at first, but I can reliably repro the issue in latest VS Code, whilst 1.73.1 works fine with the same setup (although still reproduces the integrated terminal bug). When I get a moment, I'll put together a minimal repro for the extension issue just so it is testable. |
I just tested out the insider build with this fix and it looks like the terminal itself now has the environment variables set correctly. But other areas, like the test runners, don't. For example I tried running a golang test using the play button in the gutter and the tests still failed with an error about an environment variable not being set. As @aidantwoods mentioned, this worked fine in 1.73.1. |
@fedorareis thanks, maybe we have a similar check for terminals created via extensions. Will have a look |
This is working fine for me. To verify:
|
@Tyriar I'm still seeing the issue in the current insider build. I've created a minimal reproduction of the issue.
package main
import (
"errors"
"os"
)
func getVars(env string) (string, error) {
val, set := os.LookupEnv(env)
if !set {
return "", errors.New("can't find variable:" + env)
}
return val, nil
}
package main
import "testing"
func TestGetVars(t *testing.T) {
env := "BAR"
_, err := getVars(env)
if err != nil {
t.Fatalf("%s not set", env)
}
env = "FOO"
_, err = getVars(env)
if err != nil {
t.Fatalf("%s not set", env)
}
}
As @aidantwoods mentioned above this works properly in version 1.73.1 and the test passes |
@Tyriar should I file a new issue for the scenario I described above or will this issue be reopened to look into it? |
@fedorareis I think it's tracked in #182560 |
Does this issue occur when all extensions are disabled?: Yes
When VS Code is launched with a set but empty env var, it will drop it and treat it as unset. This breaks workflows which check for the presence of env vars (which may be empty in some cases) when running VS Code integrations, e.g. running tests, running the debugger.
Steps to Reproduce:
FOO="" BAR="test" code .
[[ -v FOO ]] && echo "foo set"
, and then[[ -v BAR ]] && echo "bar set"
FOO
is missing,BAR
is setCompare with running in a terminal manually, with an empty
FOO
:Of the available historical downloads, I found that vscode 1.73.1 still replicates the above, but does seem to correctly pass the empty env vars down to other processes (e.g. the debugger).
The text was updated successfully, but these errors were encountered: