MinGW sh.exe must NOT be in your path
Asked Answered
M

6

44

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;
Mozellamozelle answered 26/12, 2016 at 15:23 Comment(5)
check for C:/Program Files/Git/user/bin in your path. You have GIT installed alongside with its shell.Bluebottle
Remove it from your PATH then?Harshman
As stated I have already looked in my PATH and I do not see any references to /Git/ or sh.exeMozellamozelle
@Septimus where are you getting the value of PATH from? I'll take a guess that what you've posted is the system PATH variable, and that you also have a user PATH that contains C:/Program Files/Git/user/binRetroact
Possible duplicate of cmake problems in WindowsTrimerous
B
77

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

Boiney answered 14/7, 2017 at 13:19 Comment(1)
if you're using CLion, what @Boiney means is, that you should go to File -> Settings -> Build, Execution, Deployment -> CMake and where it says CMake options paste -DCMAKE_SH="CMAKE_SH-NOTFOUND"Eal
F
7

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.

Franciskus answered 12/4, 2017 at 12:48 Comment(1)
that was useful, ty.Perfectionist
C
6

Just add

set(DCMAKE_SH="CMAKE_SH-NOTFOUND")

to your

CMakeLists.txt file

Computer answered 25/10, 2019 at 13:22 Comment(1)
This or the response by @Boiney is the correct answer, imho. Asking the user to change their PATH variable, possibly/probably affecting other applications is not ideal (I prefer to edit the CMakeLists file so that I have a reference of the fix for next time).Scimitar
R
1

It's the problem of your git's path.
I assume you are using the Clion, just check if you have added %gitpath%\binto your path, that's where the problem is. You should use %gitpath%\cmdinstead, typically for me it's D:\Git\cmd.Since the former one includes sh.exe in your path which results in the error.

Ringnecked answered 18/10, 2019 at 12:56 Comment(2)
This answer does not add anything new to existing answer, posted between 1 and 2 years ago.Irresistible
I seem to have the latter (%gitpath%\cmd). However, "which sh.exe" returns: "/usr/bin/sh.exe" I am using gitbash on windows.Congratulatory
D
0

I like @Elia's answer, but if you are using CLion, it uses the CodeBlocks - MinGW Makefiles CMake generator which doesn't have the sh.exe checking problem. Add this to your CMake line:

-G "CodeBlocks - MinGW Makefiles"
Denny answered 3/6, 2020 at 15:37 Comment(0)
J
0

Not exactly this setup (working from terminal here), but got the same error. In my case, sh.exe was not in my path, but was built into the terminal I was using (cmder). Switching to regular CMD worked for me.

Jocko answered 5/2, 2021 at 2:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.