CLion在使用WSL时出错



我看到WSL2的CLion错误

CMake error at usr/share/cmake-3.21/Modules/CMakeDetermineSystem.cmake:188 (file): file failed to open for writing (Permission denied):
CMake Error: Could not open file for write in copy operation files/cmake-build-debug/CMakeFiles/3.21.0/CMakeSystem.cmake.tmp
CMake Error: : System Error: Inappropriate ioctl for device
CMake Error at /usr/share/cmake-3.21/Modules/CMakeDetermineCompilerId.cmake:334 (file):
file problem creating directory:
...
....
CMake Error at /usr/share/cmake-3.21/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"/usr/bin/cc"
is not able to compile a simple test program.
It fails with the following output:
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:13 (project)

-- Configuring incomplete, errors occurred!
CMake Error: Cannot open file for write: cmake-build-debug/CMakeCache.txt.tmp035f3
CMake Error: : System Error: Inappropriate ioctl for device
CMake Error: Unable to open cache file for save. cmake-build-debug/CMakeCache.txt
CMake Error: : System Error: Inappropriate ioctl for device

我试着:

  • 添加wsdl .conf文件
# /etc/wsl.conf
[automount]
options = "metadata"
enabled = true
  • 通过运行以下命令
  • 关闭WSL
wsl --shutdown

但是刷新后显示

Cannot save file \wsl$UbuntuhomeCMakeFilesclion-environment.txt

感谢您的帮助

我也遇到过类似的情况。

我的Windows用户是管理员,所以我怀疑WSL没有足够的权限,我尝试将WSL的默认用户切换为root。

ubuntu config --default-user root

下面的图片显示了切换到root后的CLion状态。CLion地位

仍然有错误,但它可以检测CMake,我现在可以使用CMake来构建程序。

最后,这是我原来的错误信息。

CMake Error: Could not open file for write in copy operation /mnt/c/Users/Administrator/AppData/Local/Temp/cmake_check_environment1/_build9958369055144970030/CMakeFiles/3.22.1/CMakeSystem.cmake.tmp
CMake Error: : System Error: Inappropriate ioctl for device
CMake Error at /usr/share/cmake-3.22/Modules/CMakeDetermineSystem.cmake:193 (configure_file):
configure_file Problem configuring file
Call Stack (most recent call first):
CMakeLists.txt:1 (project)
...
....
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:56 (try_compile):
Unknown extension ".c" for file
/mnt/c/Users/Administrator/AppData/Local/Temp/cmake_check_environment1/_build9958369055144970030/CMakeFiles/CMakeTmp/testCCompiler.c
try_compile() works only for enabled languages.  Currently these are:
C CXX
See project() command to enable other languages.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)

-- Check for working C compiler: /usr/bin/cc - broken
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
The C compiler
"/usr/bin/cc"
is not able to compile a simple test program.
It fails with the following output:


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

-- Configuring incomplete, errors occurred!

最新更新