【问题标题】:Temporarily remove one variable of environment PATH in Windows [duplicate]在 Windows 中临时删除一个环境 PATH 变量 [重复]
【发布时间】:2019-08-19 13:25:25
【问题描述】:

我使用 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 中执行此操作。

【问题讨论】:

    标签: windows cmake path environment-variables mingw


    【解决方案1】:

    在运行cmake之前尝试在命令行环境中运行它:

    set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
    

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

    【讨论】:

    • 感谢您的回复。我也想知道linux是怎么做的。你能告诉我吗?
    • 请查看question Linux 案例的答案。
    猜你喜欢
    • 2015-01-11
    • 2017-08-16
    • 2013-08-04
    • 2019-04-12
    • 2011-02-14
    • 2011-03-05
    • 1970-01-01
    • 2015-07-29
    • 2017-06-15
    相关资源
    最近更新 更多