If you add/change some environment variables (e.g. PATH) on windows, even after restarting 'VS Code' it will not be available in VS Code integrated terminals.
But if you open that terminal from windows (Command Prompt/Powershell/...) it will have those new/updated values!!
What should I do to refresh those environment variables? (without restart or log-out)
Due to how Windows applies environment variables, you most likely need to restart apps for them to pick up the change, including explorer.exe . Restarting the machine is reccomended (but not required) and ensures all apps are run with the PATH change.
To refresh the environment variables in PowerShell, retrieves the environment variables and assign them $Env:Path to reload the environment variable path in the PowerShell. After reloading the path in PowerShell, you don't need to restart the PowerShell ISE or terminal.
You can stop any running command by pressing Ctrl + C on your keyboard.
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.
Chocolatey comes with a RefreshEnv.cmd
utility for this purpose, which worked for me. More convenient than opening other code
instances.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With