Jeff Esposito
Jeff Esposito

Reputation: 21

vscode terminal running cmd.exe loads the path incorrectly

I am running on . I've configured my to be .exe.

When I open up the the Command Prompt and look at the , I can see that it's changed C:\Program Files\nodejs to C:\Program Files (x86)\nodejs.

When I run cmd.exe directly, (not inside vscode), the PATH is correct.

I know that Windows plays games with the Program Files directory, but I don't understand whats going on here.

Here is what I see when running cmd outside of vscode:

Microsoft Windows [Version 10.0.16299.1029]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\jeff>path
PATH=C:\Python37\Scripts\;C:\Python37\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp;C:\oracle\product\11.2.0\client_1\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\app\jefforacle\product\12.1.0\client_1\bin;c:\jdk8u72\jdk1.8.0_72\bin;C:\ProgramData\Oracle\Java\javapath;C:\apache-maven-2.0.9\bin;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE;C:\Program Files (x86)\WinZip;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;L:\prj\defaults\code\bin;f:\apps\exec;L:\Prj\JavaDflts\code\BIN;C:\Program Files (x86)\AccuRev\bin;C:\Program Files (x86)\WinMerge;c:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\doxygen\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\AMD\ATI.ACE\Core-Static;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Users\jeff\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files (x86)\Microsoft Emulator Manager\1.0\;C:\Program Files\MariaDB 10.1\lib;C:\Program Files\PuTTY\;C:\Program Files\Git\cmd;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Gradle\gradle-5.4.1\bin;C:\Users\jeff\AppData\Local\Android\Sdk\tools;C:\Users\jeff\AppData\Local\Android\Sdk\tools\bin;C:\Users\jeff\AppData\Local\Android\Sdk\platform-tools;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\nodejs\;C:\Users\jeff\AppData\Local\Microsoft\WindowsApps;C:\Users\jeff\AppData\Local\GitHubDesktop\bin;C:\Users\jeff\AppData\Roaming\npm;

C:\Users\jeff>where node

C:\Program Files\nodejs\node.exe

And here is what I see when running inside vscode:

Microsoft Windows [Version 10.0.16299.1029]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\jeff>path
PATH=C:\Python37\Scripts\;C:\Python37\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp;C:\oracle\product\11.2.0\client_1\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\app\jefforacle\product\12.1.0\client_1\bin;c:\jdk8u72\jdk1.8.0_72\bin;C:\ProgramData\Oracle\Java\javapath;C:\apache-maven-2.0.9\bin;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE;C:\Program Files (x86)\WinZip;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;L:\prj\defaults\code\bin;f:\apps\exec;L:\Prj\JavaDflts\code\BIN;C:\Program Files (x86)\AccuRev\bin;C:\Program Files (x86)\WinMerge;c:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\doxygen\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\AMD\ATI.ACE\Core-Static;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Users\jeff\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files (x86)\Microsoft Emulator Manager\1.0\;C:\Program Files\MariaDB 10.1\lib;C:\Program Files\PuTTY\;C:\Program Files\Git\cmd;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Gradle\gradle-5.4.1\bin;C:\Program Files (x86)\nodejs\;C:\Users\jeff\AppData\Local\Android\Sdk\tools;C:\Users\jeff\AppData\Local\Android\Sdk\tools\bin;C:\Users\jeff\AppData\Local\Android\Sdk\platform-tools;;C:\Program Files\Microsoft VS Code\bin;C:\Python37\Scripts\;C:\Python37\;C:\Users\jeff\AppData\Local\Microsoft\WindowsApps;C:\Users\jeff\AppData\Local\GitHubDesktop\bin;C:\Users\jeff\AppData\Roaming\npm

C:\Users\jeff>where node

INFO: Could not find files for the given pattern(s).

Upvotes: 1

Views: 868

Answers (2)

Enthus3d
Enthus3d

Reputation: 2165

If anyone in the future ends up scratching their heads over this particular problem, I’ve found another culprit, which blocked me for this particular problem on Windows:

Showcase of setting Terminal>Integrated>Env: Enable Persistent Sessions

I suspect what happens is that after you update system paths, VScode caches the old path in the terminal and persists it, EVEN AFTER RESTARTING THE IDE! In this case it persists the old node path rather than the new node one.

Toggling this option off and restarting VSCode clears that cache, and the new path is loaded in. You can also toggle the option back on after you’re done.

Upvotes: 2

Jeff Esposito
Jeff Esposito

Reputation: 21

Found it. You actually have to restart vscode after changing your path env variable in the system settings to get the new path in the cmd.exe running in the terminal window.

Stopping and restarting the terminal is not good enough.

Upvotes: 1

Related Questions