Skip to content
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

Environment variable substitution doesn't work in settings.json #592

Open
anoopknayak opened this issue Aug 29, 2023 · 2 comments
Open

Environment variable substitution doesn't work in settings.json #592

anoopknayak opened this issue Aug 29, 2023 · 2 comments

Comments

@anoopknayak
Copy link

anoopknayak commented Aug 29, 2023

I have a vscode workspace with the workspace settings as follows:

{
  "go.toolsEnvVars": {
    "GO": "${env:GO}",
    "GOBIN": "${env:GOBIN}",
    "GONOPROXY": "${env:GONOPROXY}",
    "GOPATH": "${env:GOPATH}",
    "GOPRIVATE": "${env:GOPRIVATE}",
    "GOPROXY": "${env:GOPROXY}",
    "GOROOT": "${env:GOROOT}",
    "GOSUMDB": "${env:GOSUMDB}",
    "USE_ATHENS_GO_PROXY": "${env:USE_ATHENS_GO_PROXY}"
  },
  "go.goroot": "${env:GOROOT}"
}

direnv extension logs picks up the value correctly but the Go extension complains saying that ${env:GOROOT} is not a valid goroot.

Is direnv the first extension to start or can that be guaranteed in any way so that the environment variables are loaded before any other extension?

@mkhl
Copy link
Contributor

mkhl commented Aug 29, 2023

Is direnv the first extension to start or can that be guaranteed in any way so that the environment variables are loaded before any other extension?

It cannot be guaranteed so it may well not be, see also #109 which is mainly about getting it to run as early as possible.

People have also shared a workaround there which I think was to open a different kind of file first, like markdown, so the go extension would run later?

That said I would have assumed that vscode resolves the settings before loading any extensions, in which case your snippet would actively prevent this extension from affecting the go extension.
Do you think you might be able to check that?

@anoopknayak
Copy link
Author

Do you think you might be able to check that?

Sorry, I missed replying to this. I'm not exactly sure how to check this. What I did currently was to look at the Extension Host logs. From that logs I see that the direnv extension is loading before golang extension (which is an improvement from last time I checked), but I still face the same issue. It looks like workspace settings.json never resolves the direnv variables and I assume it might be resolving the env vars before loading any extensions...

Output from extension host is as below:

2023-11-06 21:30:48.943 [info] ExtensionService#_doActivateExtension vscode.emmet, startup: false, activationEvent: 'onLanguage'
2023-11-06 21:30:48.952 [info] ExtensionService#_doActivateExtension mkhl.direnv, startup: false, activationEvent: 'onLanguage'
2023-11-06 21:30:48.992 [info] ExtensionService#_doActivateExtension vscode.git-base, startup: true, activationEvent: '*', root cause: vscode.git
2023-11-06 21:30:49.011 [info] ExtensionService#_doActivateExtension vscode.git, startup: true, activationEvent: '*'
2023-11-06 21:30:49.051 [info] ExtensionService#_doActivateExtension vscode.github, startup: true, activationEvent: '*'
2023-11-06 21:30:49.115 [info] ExtensionService#_doActivateExtension ms-vscode.makefile-tools, startup: true, activationEvent: 'workspaceContains:**/makefile,**/Makefile,**/GNUmakefile'
2023-11-06 21:30:49.142 [info] ExtensionService#_doActivateExtension golang.go, startup: true, activationEvent: 'workspaceContains:*.go,*/*.go,*/*/*.go'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants