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.`
尝试了我能找到的所有方法来修复(创建安装路径的环境变量,重新安装,从源代码安装)但这些都不起作用,我也尝试在bash上运行它(我通常使用zsh)但仍然没有结果
尝试以下命令:
hash -r
这将导致 shell 忘记其 CMake 的缓存位置,并在此过程中重置环境以允许新安装的版本优先。来自 bash 中的
help hash
:
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
无论如何,我的错误是类似的:
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/home/user/.local/share/cmake-3.25
cmake version 3.25.0-rc1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
我已经使用
apt
在 Ubuntu 上安装了 cmake。然而,系统仍在我的主目录中寻找 cmake 安装。
我只是做了一个到系统目录的链接:
$ ln -s /usr/share/cmake-3.25 ~/.local/share/
问题解决了!
$ cmake --version
cmake version 3.25.0-rc1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
我必须重新安装我的 cmake 才能纠正同样的错误。
sudo apt-get remove cmake cmake-data
sudo -E add-apt-repository -y ppa:george-edison55/cmake-3.x
sudo -E apt-get update
sudo apt-get install cmake