I added a directory to my PATH but the terminal in my VS Code doesn't recognize a command(exe) that I'm trying to run from that directory. The terminal uses cmd not power shell. What am I missing?
13 Answers
Restarted my computer and it worked :) Apparently VS Code didn't recognize the changes.
4 Comments
For me, a simple restart of VSC did the trick.
3 Comments
code in a cmd window. Then it picked up the updated PATH.If your VS Code terminal shows "Session Restored" after restarting, then it may still be using the variables from before you rebooted! If this happens, close and re-open the vscode window, or kill and restart the terminal tab.
1 Comment
Clicking the bin/trash icon on the terminal to properly kill it and then CTRL + ' to open a new terminal works best. No need to close the app or shut down your PC.
2 Comments
Sometimes this problem can happen when you misuse .bash_profile and .bashrc.
As mentioned in many materials, .bash_profile is executed for interactive login shells, and .bashrc is executed for interactive non-login shells.
VSCode terminal is interactive non-login shells. So, be sure you have correctly define your PATH and other environment variables in .bashrc
Comments
I had this issue but all of the previous solutions in this question did not work. I found that on Windows 11 doing a custom Python install the PYTHONPATH env variable had not been set. Creating and setting up the PYTHONPATH variable, and then restarting terminals fixed the same issue for me.
1 Comment
PYTHONPATH is used only by Python (python.exe and pythonw.exe) to find Python modules (dynamically loaded libraries) imported in Python scripts as it can be read in the Python documentations Command line and environment, Using Python on Windows, Modules. This answer is related therefore only for Python script programmers and not for VS Code users in general.If nothing works and you don't want to restart your computer.
For windows;
- Open a command prompt (outside vscode) and type
echo %PATH% - Copy the path
- Open your terminal in vscode and type
PATH=<your-path>(replace <your-path> with the output)
Note: This is a temporary solution and goes away if you close the terminal and open a new one.
Comments
Another point of info that might solve the problem for some people. It's not obvious, but if you have multiple instances of VSCode open and you close one of them and relaunch it, it will pick up state from the other instances that are still open. So if you're trying to figure out why VSCode refuses to pick up new environment variables even after you've closed and reopened it, check that you don't have another VSCode process running at the same time as it will "help" the new process get started more quickly, sabotaging your attempt to solve the problem.
Comments
For me, it turns out that VS Code was not on my Path even though it should have automatically been added after the install. This could be the case if you use the command 'code' and it is not recognized. Adding
C:\Users\{Username}\AppData\Local\Programs\Microsoft VS Code to my User PATH and restarting the terminal (and VS Code) fixed the issue on my machine.

Pathshould take a look on: What is the reason for "X is not recognized as an internal or external command, operable program or batch file"? That long answer explains in full details how the most important environment variablePATHis managed by Windows and used by applications like the Windows Command Processor (cmd.exe) , PowerShell, Windows Script Host (cscript.exeandwscript.exe) and other executables like VS Code and other IDEs.