I am using Windows 10.
I keep encountering the error message The system cannot find the path specified
whenever I run a python script, start a cygwin terminal, bash script ...
There is no meaningful error message to pinpoint the exact cause. I suspect this is due to one of the pathnames in PATH variable to be pointing to non-existent path. How can I find out which pathname is causing it?
Powershell Path Test
Here is a one line Powershell script that will test all paths in your PATH Environment Variable exist. It will report OK or MISSING for each path. If any paths are listed as missing, you should manually remove them from the Environment Variable.
@($env:path -split ";").ForEach({ if($_) {$result = 'MISSING |';if(Test-Path -path $_) { $result = ' OK |'};-join($result, ' ', $_); }})
Option 2
Run the following from an Elevated CMD prompt. This ensures all windows paths and executables are available, permissions correct and non corrupt. After running it, it will give further instructions if needed.
sfc /scannow
Option 3
Open the Registry Editor (regedit.exe). Check the following (if the exist) for invalid not wanted paths. As Usual, BACKUP Registry Before Making Changes.
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
Option 4
Get the small utility Process Monitor from Microsoft's site. Process Monitor is an advanced monitoring tool for Windows that shows real-time file system, Registry and process/thread activity. You WILL find the offending path using this tool.
Some Filters to try and narrow down the offender:
After you find what you're looking for, and fix the issue, you will at minimum need to close and re-open your prompt before re-testing, but may also need to perform a reboot.
If removal of the offending record can be uninstalled vs just removed, do this as a bad/outdated Filesystem path may only be half the issue, additionally requiring a registry record update. The uninstaller should solve both.
If changes to to your Registry are needed, Ensure you first create a backup using regedit.exe.