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

**URL:** https://discourse.cmake.org/t/cmake-error-operation-not-permitted-in-new-wsl-ubuntu-session/3681
**Category:** Usage
**Created:** [July 2, 2021, 12:37pm UTC](https://discourse.cmake.org/t/cmake-error-operation-not-permitted-in-new-wsl-ubuntu-session/3681 "2021-07-02T12:37:37Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![DavidA](https://discourse.cmake.org/user_avatar/discourse.cmake.org/davida/32/128_2.png) [@DavidA](https://discourse.cmake.org/u/DavidA)
#### Post date: [July 2, 2021, 12:37pm UTC](https://discourse.cmake.org/t/cmake-error-operation-not-permitted-in-new-wsl-ubuntu-session/3681/1 "2021-07-02T12:37:38Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

### Author: ![DavidA](https://discourse.cmake.org/user_avatar/discourse.cmake.org/davida/32/128_2.png) [@DavidA](https://discourse.cmake.org/u/DavidA)
#### Post date: [July 2, 2021, 1:44pm UTC](https://discourse.cmake.org/t/cmake-error-operation-not-permitted-in-new-wsl-ubuntu-session/3681/2 "2021-07-02T13:44:13Z")

</div>

I guess this is a WSL issue.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 2, 2021, 3:14pm UTC](https://discourse.cmake.org/t/cmake-error-operation-not-permitted-in-new-wsl-ubuntu-session/3681/3 "2021-07-02T15:14:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![DavidA](https://discourse.cmake.org/user_avatar/discourse.cmake.org/davida/32/128_2.png) [@DavidA](https://discourse.cmake.org/u/DavidA)
#### Post date: [July 5, 2021, 11:59am UTC](https://discourse.cmake.org/t/cmake-error-operation-not-permitted-in-new-wsl-ubuntu-session/3681/4 "2021-07-05T11:59:51Z")

</div>

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

---

<div class="post-metadata">

### Author: ![AltayAkkus](https://discourse.cmake.org/user_avatar/discourse.cmake.org/altayakkus/32/2554_2.png) [@AltayAkkus](https://discourse.cmake.org/u/AltayAkkus)
#### Post date: [June 29, 2022, 8:27pm UTC](https://discourse.cmake.org/t/cmake-error-operation-not-permitted-in-new-wsl-ubuntu-session/3681/6 "2022-06-29T20:27:17Z")

</div>

> [@ben.boeckel](#):
>
> Can you get logs as to what operation was not permitted?

Here are my complete logs from Clion

```auto
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

```

---

<div class="post-metadata">

### Author: ![mavaddat](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mavaddat/32/2702_2.png) [@mavaddat](https://discourse.cmake.org/u/mavaddat)
#### Post date: [August 23, 2022, 10:06pm UTC](https://discourse.cmake.org/t/cmake-error-operation-not-permitted-in-new-wsl-ubuntu-session/3681/7 "2022-08-23T22:06:37Z")

</div>

Also works:

```pwsh
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 |

---

<div class="post-metadata">

### Author: ![endolith](https://discourse.cmake.org/user_avatar/discourse.cmake.org/endolith/32/3057_2.png) [@endolith](https://discourse.cmake.org/u/endolith)
#### Post date: [January 4, 2023, 8:01pm UTC](https://discourse.cmake.org/t/cmake-error-operation-not-permitted-in-new-wsl-ubuntu-session/3681/8 "2023-01-04T20:01:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![zhangshaos](https://discourse.cmake.org/user_avatar/discourse.cmake.org/zhangshaos/32/3664_2.png) [@zhangshaos](https://discourse.cmake.org/u/zhangshaos)
#### Post date: [August 2, 2023, 9:03am UTC](https://discourse.cmake.org/t/cmake-error-operation-not-permitted-in-new-wsl-ubuntu-session/3681/9 "2023-08-02T09:03:48Z")

</div>

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](https://github.com/microsoft/WSL/issues/4257#issuecomment-507799403).
