Closed award999 closed 4 months ago
There's also the option of just adding to the terminal environment directly using the ExtensionContext
:
context.environmentVariableCollection.clear();
context.environmentVariableCollection.prepend(
"PATH",
"/path/to/usr/bin:",
{ applyAtShellIntegration: true }
);
for (const variable in configuration.swiftEnvironmentVariables) {
context.environmentVariableCollection.replace(
variable,
configuration.swiftEnvironmentVariables[variable],
{ applyAtShellIntegration: true }
);
}
Using this approach the user will have the environment automatically populated in their VS Code terminal without having to launch a special profile. The only minor annoyance being that modifying certain variables (e.g. PATH
) triggers a warning before the terminal will be updated:
@matthewbastien so that appears every time you start up a terminal window or only for existing terminal windows?
@adam-fowler the warning will only appear for existing terminal windows that need to be reloaded to capture new environment variables.
@matthewbastien if I disable swift.enableTerminalEnvironment
and then create a new terminal with the swift profile, swift.swiftEnvironmentVariables
values are added but which swift
still indicates /usr/bin/swift
is being used not the selected toolchain path.
Verified with 8d6f68f
Is your feature request related to a problem? Please describe. I've made the mistake a few times where I have select a toolchain in vscode and it has been built for via tasks. I then go to the integrated vscode terminal to issue to run some swift command that is a different version of swift.
Describe the solution you'd like You can provide different terminal profiles https://code.visualstudio.com/api/references/vscode-api#TerminalProfileProvider so we could provide a Swift terminal profile with selected toolchain in the PATH so that user can select this swift profile in settings, for example
terminal.integrated.defaultProfile.osx
Describe alternatives you've considered N/A
Additional context N/A