VS Code Refresh Integrated Terminal Environment Variables without Restart/Logout
This manually resets the path variable in the specific PowerShell terminal.
$env:Path = `
[System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + `
[System.Environment]::GetEnvironmentVariable("Path","User")
Chocolatey comes with a RefreshEnv.cmd
utility for this purpose, which worked for me. More convenient than opening other code
instances.
I got the following to work (at least on VS Code 1.62.00).
- Restart VS Code
- Open a new terminal (via
Terminal->New Terminal
orCtrl+Shift+`
or with the+
on the top right of the terminal window), do NOT use the existing terminals orView->Terminal
.
Make sure that you are on the new terminal, as many times after restarting VS Code it might try to restore the old terminal.
The new terminal should be up to date.
You need to run the following line in a new window of one of your terminals (Command Prompt, Powershell, ...):
code
It will open 'VS Code' once from them.
Now you can close and re-open 'VS Code' again as many time as you want using its normal shortcuts and have your environment variables.