0

I have a strange issue with both CMD and Powershell on Windows 10 that has been giving me some trouble. An unrelated scriptwas failing when running curl, and after some investigation it looks like a CMD and Powershell issue.

When I run curl in CMD, I get the following error:

C:\Users\****>curl
Cannot find file at '..\\lib\curl\tools\curl-8.6.0_1-win64-mingw\bin\curl.exe' (C:\WINDOWS\lib\curl\tools\curl-8.6.0_1-win64-mingw\bin\curl.exe). This usually indicates a missing or moved file.

The same happens in PowerShell, though in that case I have to write curl.exe (plain curl aliases to Invoke-WebRequest).

This path does not exist. It is not present in PATH (or any other environment variable), either, and I can't figure out why CMD/Powershell is trying to look for curl there. I have tried putting C:\Windows\System32 (where curl is actually located) at the beginning of PATH, but this didn't work.

Confusingly, where works just fine and doesn't show anything weird:

C:\Users\****>where curl
C:\Windows\System32\curl.exe

Any help is appreciated, let me know if I need to provide some more information.

Syst3ms
  • 11
  • Does running C:\windows\system32\curl.exe with full path show the same message? Can you check whether HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\curl.exe exists via regedit? The error message is definitely neither Cmd nor PS; you're somehow running a Chocolatey shim .exe (which exists somewhere on your system, but its job is to run another .exe that doesn't exist). – u1686_grawity Mar 27 '24 at 09:54
  • Please add your entire PATH to your post. – harrymc Mar 27 '24 at 10:27
  • @u1686_grawity Oh that's definitely it. I recall replacing the default curl with that but I had no idea it did that. The eternal curse of doing something stupid while trying to solve a tech problem. I'll replace it with an actual curl executable. – Syst3ms Mar 27 '24 at 10:31
  • Nothing should ever be installed to %WinDir% - that is never the way to install software (except for driver installations and the handful of user modifiable config files within %WinDir%\System32\drivers\etc, %WinDir% is off-limits for modifications - this explains why). There are five default locations for installing software: %ProgramFiles%, %ProgramFiles(x86)%, %ProgramData%, %LocalAppData%, and %AppData%. If Chocolatey has been installed, or is installing software, to %WinDir%, it's configured incorrectly. – JW0914 Mar 27 '24 at 12:15

1 Answers1

1

As pointed out in the comments, it is indeed running curl in the correct location, but the executable is a Chocolatey shim which tries to defer to another one.

For some reason I had manually replaced the curl inside System32 with such an .exe to solve a different issue (which is as stupid as it sounds, I know). I re-replaced it with an actual curl executable and it works perfectly now.

Syst3ms
  • 11
  • This is an incomplete answer: "I had manually replaced curl with such an .exe to solve a different issue..." Manually replaced what curl.exe? | "I re-replaced it with an actual curl executable..." Replaced what curl.exe (nothing should ever be installed to %WinDir% - that is not the way to install anything, as it will get overwritten by sfc /scannow)? – JW0914 Mar 27 '24 at 12:08