# error: source file is not valid UTF-8

**URL:** https://discourse.cmake.org/t/error-source-file-is-not-valid-utf-8/10148
**Category:** Code
**Created:** [February 21, 2024, 1:30pm UTC](https://discourse.cmake.org/t/error-source-file-is-not-valid-utf-8/10148 "2024-02-21T13:30:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![shokarta](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/e36b37/32.png) [@shokarta](https://discourse.cmake.org/u/shokarta)
#### Post date: [February 21, 2024, 1:30pm UTC](https://discourse.cmake.org/t/error-source-file-is-not-valid-utf-8/10148/1 "2024-02-21T13:30:30Z")

</div>

Hello,

so the situation is: from Win10 64 I run Virtual Machine where the guest is MacOS, From Win10 I share a folder with all projects (sources as well as builds folders). When opening projects and run Cmake which creates build folder on guest macOS, all is fine, when the Cmake creates build folder on host shared folder location, it gives an error:  
`error: source file is not valid UTF-8`  
to me, I think this is the false report, the cmake from macOS creates the build files itself, so its not reading any files from another drive (even virtualy shared).

[Attached](https://gitlab.kitware.com/cmake/cmake/uploads/581eb511dcd17bd756c8ae161564c3dc/cmake_bug_encoding.zip) you can see all files form build directory created from guest to host virtualy shared folder

I tries with CMake 3.27.7, but same applies for 3.24.4

PS: what is REALY interested, that if I configure the project to real iOS device, then CMake wiill handle fine without this error. But when I configure the project for iOS Simulator, this error appears I have checked with QT Support, and we discovered this is CMake topic rather then QT topic

Is there anything which can be done from CMake side? to somehow force creating UTF8 encoding?

---

<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: [February 27, 2024, 1:52pm UTC](https://discourse.cmake.org/t/error-source-file-is-not-valid-utf-8/10148/2 "2024-02-27T13:52:38Z")

</div>

What is providing that error message? I don’t see the text of it in CMake itself at least.

---

<div class="post-metadata">

### Author: ![shokarta](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/e36b37/32.png) [@shokarta](https://discourse.cmake.org/u/shokarta)
#### Post date: [February 27, 2024, 7:29pm UTC](https://discourse.cmake.org/t/error-source-file-is-not-valid-utf-8/10148/3 "2024-02-27T19:29:16Z")

</div>

well…  
i run QT6, i tried to find out the issue with QT support and they actually told me to open the bug report here direcly on CMake, see:  
[[QTBUG-122438] iOS Simulator wont handle CXX on fresh project but example works - Qt Bug Tracker](https://bugreports.qt.io/browse/QTBUG-122438)

lateron i found out its common virtual machine problem, see:  
[mount - Error source file is not valid UTF-8 when sharing project code from Ubuntu host to macOS guest - Stack Overflow](https://stackoverflow.com/questions/61336405/error-source-file-is-not-valid-utf-8-when-sharing-project-code-from-ubuntu-host)

---

<div class="post-metadata">

### Author: ![JFLarvoire](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jflarvoire/32/5801_2.png) [@JFLarvoire](https://discourse.cmake.org/u/JFLarvoire)
#### Post date: [September 4, 2025, 7:41am UTC](https://discourse.cmake.org/t/error-source-file-is-not-valid-utf-8/10148/4 "2025-09-04T07:41:12Z")

</div>

I’ve got the same problem here, with my own sources. (No QT, and no cmake either, so it’s not the culprit!)  
This is a MacOS15 VM within VMware on a Windows 11 hosts. All updates done on both sides.  
Apple clang version 16.0.0  
Did you find a workaround?
