Cmake找不到CMAKE_ROOT

syz*_*tem 0 cmake

Cmake 抛出错误

CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in

CMake Error: Error executing cmake::LoadCache(). Aborting.`
Run Code Online (Sandbox Code Playgroud)

尝试了我能找到的所有方法来修复(创建安装路径的环境变量、重新安装、从源代码安装),但这些都不起作用,我也尝试在 bash 上运行它(我通常使用 zsh),但仍然没有结果

小智 7

尝试以下命令:

hash -r
Run Code Online (Sandbox Code Playgroud)

这将导致 shell 忘记其 CMake 的缓存位置,并在此过程中重置环境以允许新安装的版本优先。来自help hashbash:

hash: hash [-lr] [-p pathname] [-dt] [name ...]
    Remember or display program locations.

    Determine and remember the full pathname of each command NAME.  If
    no arguments are given, information about remembered commands is
    displayed.

    Options:
      ...
      -r        forget all remembered locations
Run Code Online (Sandbox Code Playgroud)