ENOENT error suddently appearing for both VSCode Julia and Atom editor on a Windows 10 machine

I am facing a very strange problem on one of my Windows 10 64-bit machines with Julia 1.4.0.

The VS Code Julia extension (version 0.15.x) were working fine. Then one day, maybe after a Windows update or installing Slack - couldn’t remember clearly, I started VS Code fresh with a Julia file and got the “Could not start the julia language server. Make sure the configuration setting julia.executablePath points to the julia binary.” error.

In addition, if I run debugger on the active Julia file, I get the following error:

“spawn path ENOENT "C:\Julia-1.4.0\bin\julia.exe" --startup-file=no --history-file=no -e "using Pkg; println(dirname(Pkg.Types.Context().env.project_file))" (exited with error code ENOENT)”

Similar issue also occurred in the Atom editor. I cannot update or install any package due to ENOENT error while accessing a temporary folder Atom installer supposedly created - I checked and that folder was truly missing. (I will post in the Juno category the detailed error log as it’s quite long.)

I have the Julia binary path in PATH and the same setup was working on other Windows machines. Nonetheless, I tried the following to no avail:
(1) Add the Julia bin path to “julia.executablePath” in the Julia extension config
(2) Clean uninstall Julia, delete all packages, and re-install
(3) Clean uninstall VSCode, delete all extensions, and re-install
(4) Remove all language packs and leave only English in Windows.
(5) Disable Defender firewall, and add code.exe, julia.exe, as well as the VSCode and Julia installation folders to exception list in Defender anti-virus scan. I have no other security software installed.
(6) Make sure I am the Administrator and have access to all relevant folders.

Eventually I bumped into the following which only partially worked around the problem: I had to BOTH set the “julia.executablePath” AND set “julia.environmentPath” in the Julia extension config. This will suppress the “Could not start the julia language server” error, allow the extension to work (e.g. execute file, linter, debuger seem to work).

However, the status bar shows “Julia env: [loading]” forever, REGARDLESS what I put for “julia.environmentPath”. Whether I point it to the correct, default environment folder for v1.4 or point it to any other folder, it’s the same.

Because both VS Code and Atom suddenly developed this strange problem with finding paths, I wonder if the root cause is something related to Windows or some application I installed on Windows. However, other apps using web frameworks seem to work fine, e.g. OneNote, Slack. And other PCs with the same Windows updates and same apps installed are working fine, too.

I searched the Internet and found no description of this weird issue. Have spent hours on this because the PC having this problem happens to be my best power horse.

Please help if you have any information or idea. Thanks!!!

After many hours I finally solved this problem.

The cause: for some reason system environmental variable has “ComSpec” set to string “path”, which is totally wrong.

It turns out ComSpec should point to the command line interpreter (see https://en.wikipedia.org/wiki/COMSPEC). But “path” is not a valid path, so this messed with programs that issue commands through the command line interpreter.

After removing the environmental variable, everything returns normal.

I still don’t know how this ComSpec variable was created in the first place.