CMake Error 'Operation not permitted' in new WSL Ubuntu session

We have just installed WSL Ubuntu 20.04 on Windows and installed CMake v.3.20.5. Our CMake project is known to work but we see:

CMake Error at /usr/local/share/cmake-3.20/Modules/CheckIncludeFile.cmake:57 (configure_file):
  Operation not permitted
Call Stack (most recent call first):
  /usr/local/share/cmake-3.20/Modules/FindThreads.cmake:146 (CHECK_INCLUDE_FILE)
  Kernel/CMakeLists.txt:80 (find_package)

where CMakeLists.txt:80 contains:

find_package(Threads REQUIRED)

The build-essential package is installed so pthreads should be there.

Any ideas what may be wrong please?

I guess this is a WSL issue.

Can you get logs as to what operation was not permitted?

@ben.boeckel Thanks for your reply. The problem seems to be fixed after a laptop reboot.

2 Likes

Here are my complete logs from Clion

CMake Error at /usr/local/share/cmake-3.22/Modules/CMakeDetermineSystem.cmake:193 (configure_file):
  Operation not permitted
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- The C compiler identification is GNU 9.4.0
CMake Error at /usr/local/share/cmake-3.22/Modules/CMakeDetermineCCompiler.cmake:226 (configure_file):
  Operation not permitted
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- The CXX compiler identification is GNU 9.4.0
CMake Error at /usr/local/share/cmake-3.22/Modules/CMakeDetermineCXXCompiler.cmake:226 (configure_file):
  Operation not permitted
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - works
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at /usr/local/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:85 (configure_file):
  Operation not permitted
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ - works
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/local/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:78 (configure_file):
  Operation not permitted
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!
See also "/mnt/c/Users/Altay/AppData/Local/Temp/cmake_check_environment/_build1400723743840371038/CMakeFiles/CMakeOutput.log".
See also "/mnt/c/Users/Altay/AppData/Local/Temp/cmake_check_environment/_build1400723743840371038/CMakeFiles/CMakeError.log".

Error code: 1

Also works:

wsl --shutdown
wsl --list --verbose

Output:

NAME STATE VERSION
* Ubuntu-22.04 Running 2
docker-desktop-data Stopped 2
Ubuntu-20.04 Stopped 2
AlmaLinux-8 Stopped 2
1 Like

Rebooting fixed it for me, too. I had uninstalled and reinstalled WSL prior.

I meet the same problem after moving WSL from C: to D:.
The solution in the link below works.
Mounted filesystem issue on Debian WSL when running CMake · Issue #4257 · microsoft/WSL · GitHub.