暂时移除Windows中的一个环境变量PATH

Temporarily remove one variable of environment PATH in Windows

我用 CMake 构建我的项目。

我想生成"MinGW Makefiles", 但是 CMake 抛出这个错误:

CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeMinGWFindMake.cmake:12 (message):
  sh.exe was found in your PATH, here:

  C:/Program Files/Git/usr/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.

  If you want to use a UNIX shell, then use MSYS Makefiles.

Call Stack (most recent call first):
  CMakeLists.txt:3 (project)


CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

好像只有这个需要删除:

C:\Program Files\Git\cmd

在我的环境变量Path.

所以我想知道如何在 Windows CLI 中执行此操作。

在 运行 cmake:

之前在您的命令行环境中尝试 运行
set PATH=%PATH:C:\Program Files\Git\usr\bin;=%

这将从您的 PATH 字符串变量中删除特定路径 (C:\Program Files\Git\usr\bin;),并使用字符串 substitution.

重新分配 PATH