CMake/Ninja build error caused by long file paths on Windows
When building your React Native app for Android on Windows, you may encounter the following error:
Task :app:buildCMakeDebug[arm64-v8a] FAILEDC/C++: ninja: error: mkdir(nutrient_sdk_react_native_codegen_autolinked_build/CMakeFiles/react_codegen_nutrient_sdk_react_native_codegen.dir/react/renderer/components/nutrient_sdk_react_native_codegen): No such file or directoryWhy this happens
Windows has a default maximum file path length of 260 characters (known as MAX_PATH). During an Android build, CMake and Ninja generate deeply nested build directories with long auto-generated names. When your project is located several folders deep in your file system, the combined length of your project path and these generated directory names can exceed the 260-character limit. When that happens, Ninja is unable to create the required directories, and the build fails with a misleading “No such file or directory” error — even though the parent directories exist.
This isn’t caused by your Gradle version or your Nutrient SDK setup; it’s a Windows-specific file system limitation.
Solution
There are two ways to resolve this.
Option 1: Move your project closer to the drive root (recommended)
This is the quickest fix. Move your project to a short path near the root of your drive, for example:
C:\myapp\This reduces the total path length of all generated build files and keeps you well within the 260-character limit.
Option 2: Enable Win32 long path support on Windows
For a more permanent fix, you can lift the 260-character limit systemwide by enabling Win32 long path support via the Group Policy Editor:
- Open the Group Policy Editor by pressing Win-R, typing
gpedit.msc, and pressing Enter. - Navigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem.
- Double-click Enable Win32 long paths and set it to Enabled.
- Click OK and restart your machine.
After restarting, retry your build with npx expo run:android (or your equivalent build command).
Note — The Group Policy Editor (gpedit.msc) is available on Windows 10 Pro, Enterprise, and Education editions. It isn’t available on Windows 10 Home. If you’re on Windows Home, use Option 1 or enable long paths via the registry: Set HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled to 1.