fix: apply shell integration for environment variables
Apply shell integration to ensure extension environment variables
like PATH take precedence over user exports in shell startup files.
diff --git a/extension/src/goEnvironmentStatus.ts b/extension/src/goEnvironmentStatus.ts
index 31d5d8d..512da2d 100644
--- a/extension/src/goEnvironmentStatus.ts
+++ b/extension/src/goEnvironmentStatus.ts
@@ -304,6 +304,11 @@
}
}
+const defaultMutatorOptions: vscode.EnvironmentVariableMutatorOptions = {
+ applyAtProcessCreation: true,
+ applyAtShellIntegration: true
+};
+
/**
* addGoRuntimeBaseToPATH adds the given path to the front of the PATH
* environment variable. It removes duplicates.
@@ -333,7 +338,7 @@
// Calling this multiple times will override the previous value.
// environmentVariableCollection.clear();
if (process.platform !== 'darwin') {
- environmentVariableCollection?.prepend(pathEnvVar, newGoRuntimeBase + path.delimiter);
+ environmentVariableCollection?.prepend(pathEnvVar, newGoRuntimeBase + path.delimiter, defaultMutatorOptions);
} else {
// When '-l' or '--login' flags are set, the terminal will invoke a login
// shell again and the paths from the user's login shell will be prepended
@@ -355,7 +360,11 @@
}
terminalCreationListener = vscode.window.onDidOpenTerminal(updateIntegratedTerminal);
} else {
- environmentVariableCollection?.prepend(pathEnvVar, newGoRuntimeBase + path.delimiter);
+ environmentVariableCollection?.prepend(
+ pathEnvVar,
+ newGoRuntimeBase + path.delimiter,
+ defaultMutatorOptions
+ );
}
}
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
I spotted some possible problems with your PR:
1. You usually need to reference a bug number for all but trivial or cosmetic fixes. For the vscode-go repo, the format is usually 'Fixes golang/vscode-go#1234' or 'Updates golang/vscode-go#1234' at the end of the commit message. Should you have a bug reference?
Please address any problems by updating the GitHub PR.
When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.
To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.
For more details, see:
(In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Congratulations on opening your first change. Thank you for your contribution!
Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.
Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |