envFile setting for debugger does not default to ${workspaceFolder}/.env #2128
Labels
debug/config
Issues for config discrepancies b/n settings.json, launch.json, launch with F5, run test, debug test
Debug
Issues related to the debugging functionality of the extension.
FrozenDueToAge
Milestone
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.go version go1.17.6 linux/amd64
gopls -v version
to get version of Gopls from the VS Code integrated terminal.code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.v0.32.0
Go: Locate Configured Go Tools
command.Share the Go related settings you have added/edited
Run
Preferences: Open Settings (JSON)
command to open your settings.json file.Describe the bug
Documentation at https://github.com/golang/vscode-go/blob/master/docs/debugging.md#launchjson-attributes states that
envFile
value defaults to${workspaceFolder}/.env
. However, I found this to not be true. To properly set env vars (when running the debugger via F5 or with the green play button in theRUN AND DEBUG
VSCode Panel), I found it necessary to define alaunch.json
containingSteps to reproduce the behavior:
.env
in the root of the workspace and and make it containFOO=bar
XXX_test.go
fileAlso note that if you click the
debug test
code lens link that hovers over a specific test, theenvFile
value fromsettings.json
is properly consumed and used for the tests. So there's also a bit of inconsistency there. I would expect the following precedence when hitting F5 to run / launch the debugger:${workspaceFolder}/.env
when nothing defined insettings.json
orlaunch.json
go.testEnvFile
if defined insettings.json
envFile
if defined inlaunch.json
Screenshots or recordings
This is pretty trivial to reproduce, but if you need screenshots, let me know!
The text was updated successfully, but these errors were encountered: