# \[Issue\] CMake error invoke sh

**URL:** https://discourse.cmake.org/t/issue-cmake-error-invoke-sh/11119
**Category:** Usage
**Tags:** os:windows, comp:clang, gen:ninja
**Created:** [June 27, 2024, 3:00pm UTC](https://discourse.cmake.org/t/issue-cmake-error-invoke-sh/11119 "2024-06-27T15:00:45Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![TritiumXs](https://discourse.cmake.org/user_avatar/discourse.cmake.org/tritiumxs/32/4704_2.png) [@TritiumXs](https://discourse.cmake.org/u/TritiumXs)
#### Post date: [June 27, 2024, 3:00pm UTC](https://discourse.cmake.org/t/issue-cmake-error-invoke-sh/11119/1 "2024-06-27T15:00:45Z")

</div>

When I am using PowerShell and VS Code, CMake incorrectly invoked the sh in MSYS, and the sh in msys2 incorrectly handled Windows-style paths, which resulted in my clang not being called correctly. How should I handle this situation?

```auto
CMake Error at C:/Program Files/CMake/share/cmake-3.29/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "C:/Program Files/LLVM/bin/clang.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: 'Y:/flash-tool/libadb/CMakeFiles/CMakeScratch/TryCompile-qqomqn'

    Run Build Command(s): F:/msys64/usr/bin/ninja.exe -v cmTC_9d7d3
    [1/2] C:\PROGRA~1\LLVM\bin\clang.exe -O0 -g -Xclang -gcodeview -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -MD -MT CMakeFiles/cmTC_9d7d3.dir/testCCompiler.c.obj -MF CMakeFiles\cmTC_9d7d3.dir\testCCompiler.c.obj.d -o CMakeFiles/cmTC_9d7d3.dir/testCCompiler.c.obj -c 'Y:/flash-tool/libadb/CMakeFiles/CMakeScratch/TryCompile-qqomqn/testCCompiler.c'
    FAILED: CMakeFiles/cmTC_9d7d3.dir/testCCompiler.c.obj
    C:\PROGRA~1\LLVM\bin\clang.exe -O0 -g -Xclang -gcodeview -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -MD -MT CMakeFiles/cmTC_9d7d3.dir/testCCompiler.c.obj -MF CMakeFiles\cmTC_9d7d3.dir\testCCompiler.c.obj.d -o CMakeFiles/cmTC_9d7d3.dir/testCCompiler.c.obj -c 'Y:/flash-tool/libadb/CMakeFiles/CMakeScratch/TryCompile-qqomqn/testCCompiler.c'
    /bin/sh: line 1: C:PROGRA~1LLVMbinclang.exe: command not found
    ninja: build stopped: subcommand failed.

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:35 (project)

-- Configuring incomplete, errors occurred!

```

From the CMake output log, it is clear that the path which should have been `C:\PROGRA~1\LLVM\bin\clang.exe` has become `C:PROGRA~1LLVMbinclang.exe`.  
By the way, I had no issues configuring this project in CLion.

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [June 27, 2024, 10:14pm UTC](https://discourse.cmake.org/t/issue-cmake-error-invoke-sh/11119/2 "2024-06-27T22:14:33Z")

</div>

All programs should be of the same type, either native Windows or MSYS. Mixing them is quite error-prone.

In your case, you’re using a native CMake and clang, but Ninja is from MSYS. Use a Windows native Ninja, then it should use cmd.
