Exclude single executable from path

2

I have a small problem with my path environment on windows 10.

I'm running CLion, which uses CMake, and it spits out this error:

  sh.exe was found in your PATH, here:

  C:/Program Files/Git/bin/sh.exe

  For MinGW make to work correctly sh.exe must NOT be in your path.

  Run cmake from a shell that does not have sh.exe in your PATH.

Now, I consciously added git to my path so that I can keep using it from the command line, so I was wondering if there's a way to exclude just sh.exe from my path as I'd much prefer to keep using git from cmd.

I'm also not quite sure if git uses sh.exe so I'm reluctant to delete it outright.

The environment variable itself is:

C:/Program Files/Git/bin

Running windows 10 Build 17134

If there's a way to configure CMake/CLion to use a shell without using (that part of) the path env variable I'd be glad to hear that too.

FMashiro

Posted 2018-12-13T07:56:11.987

Reputation: 125

Answers

1

No, you cannot exclude a single file from path.

The best that you can do is to have your default path not include git and create a batch file which allows you to use the git shell and put that in your path.

That way, you can invoke C:/Program Files/Git/bin/sh.exe from, let’s say, git.bat which is in your path, but CLion won’t complain because sh.exe isn’t in your path.

Mawg says reinstate Monica

Posted 2018-12-13T07:56:11.987

Reputation: 2 744

1What if git.exe requires sh.exe to be in the path as well? If that is the case, this solution won't work. I am also unaware of a way to comprehensively check if it's the case, if you know a way I'd gladly check and report back if this solution could work :) – FMashiro – 2018-12-13T08:54:04.717

1A very good point. I guess that you can only suck it & see. Give it a try and let us know. If that won't work, I am out of ideas, sorry. – Mawg says reinstate Monica – 2018-12-13T08:57:09.303

1Thanks, I'll try this out and unless I get other suggestions I'll mark this as accepted – FMashiro – 2018-12-13T08:59:18.153