MinGW sh.exe must NOT be in your path

2019-03-12 04:34发布

问题:

Currently trying to setup my C development environment on windows with MinGW and it looks like CMAKE is giving me the following error:

sh.exe was found in your PATH, here:
C:/Program Files/Git/user/bin/sh.exe
For MinGW make to work correctly sh.exe must NOT be in your path.
Run cmake from a shill that does not have sh.exe in your PATH.
If you want to use a UNIX shell, then use MSYS Makefiles

That error is being thrown inside of CLion IDE. I am not sure if I need to change settings inside of CLion or what. I have looked at my windows path and I do not see any reference to sh.exe.

My path is as follows:

C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Nodist\bin;C:\Users\wesle\AppData\Local\Microsoft\WindowsApps;

回答1:

For me, this simple parameter passed to cmake has worked -DCMAKE_SH="CMAKE_SH-NOTFOUND".



回答2:

Check you really do not have sh.exe in your PATH by opening a Windows Command Line and typing where sh.exe. If you have this file in your path, the command will return its path (then you should remove it from your PATH) else if windows return it was not found, try to clean up the folder CMakeFiles and a file name CMakeCache.txt somewhere inside your project folder.



回答3:

If you have install git, just add gitPath/bin to your User or System environment variable PATH.

For example, I add C:\Program Files\Git\bin to my User PATH environment variable.