Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code Refresh Integrated Terminal Environment Variables without Restart/Logout

Tags:

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)

like image 333
Mostafa Aghajani Avatar asked Feb 12 '19 15:02

Mostafa Aghajani


People also ask

Do you have to restart after changing environment variables?

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.

How do you refresh an environment variable in PowerShell?

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.

How do I stop VS code Terminal running?

You can stop any running command by pressing Ctrl + C on your keyboard.


2 Answers

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.

like image 103
Mostafa Aghajani Avatar answered Sep 21 '22 19:09

Mostafa Aghajani


Chocolatey comes with a RefreshEnv.cmd utility for this purpose, which worked for me. More convenient than opening other code instances.

like image 29
Leeroy Avatar answered Sep 23 '22 19:09

Leeroy