Skip to content

fix(android): resolve two Windows build failures — bash path and CMake/Ninja absolute path#1040

Open
kevinthelago wants to merge 1 commit intosoftware-mansion:mainfrom
kevinthelago:fix/windows-cmake-ninja-absolute-path
Open

fix(android): resolve two Windows build failures — bash path and CMake/Ninja absolute path#1040
kevinthelago wants to merge 1 commit intosoftware-mansion:mainfrom
kevinthelago:fix/windows-cmake-ninja-absolute-path

Conversation

@kevinthelago
Copy link
Copy Markdown

Problem

Building the Android library on Windows fails in two distinct ways:

1. downloadPrebuiltBinaries — bash not found

Gradle calls commandLine 'bash' which on Windows resolves to C:\Windows\System32\bash.exe, the WSL relay. If WSL has no distro installed this throws:

execvpe(/bin/bash) failed: No such file or directory

Tracked in #1012.

2. buildCMakeDebug — Ninja cannot mkdir object directories

CMake/Ninja derives object file directories from absolute source paths. On Windows, Ninja converts the drive letter colon (C:) to an underscore (C_), producing:

CMakeFiles/react-native-audio-api.dir/C_/Users/.../audioapi

That path cannot be mkdir'd, so the build fails with:

ninja: error: mkdir(src/main/cpp/audioapi/CMakeFiles/react-native-audio-api.dir/C_/Users/...): No such file or directory

Tracked in #784.

Fix

android/build.gradle — detect Windows via Os.isFamily(Os.FAMILY_WINDOWS) and use Git Bash (C:\Program Files\Git\usr\bin\bash.exe) instead of the system bash. The Unix path remains unchanged.

android/src/main/cpp/audioapi/CMakeLists.txt — after globbing source files into *_ABS variables, convert each absolute path to a path relative to CMAKE_CURRENT_SOURCE_DIR using file(RELATIVE_PATH). Ninja then creates simple relative object directories with no drive letter, and the build proceeds normally.

Test plan

  • Android build completes on Windows with Git for Windows installed
  • Android build still works on macOS/Linux (Unix path unchanged)
  • Prebuilt binaries download succeeds via Git Bash on Windows

…solute path issue

On Windows, two problems block the Android build:

1. Gradle's downloadPrebuiltBinaries task calls 'bash' which resolves
   to the WSL relay (C:\Windows\System32\bash.exe). If WSL has no
   distro installed, this fails with:
     execvpe(/bin/bash) failed: No such file or directory
   Fix: detect Windows via Os.isFamily(Os.FAMILY_WINDOWS) and use
   Git Bash (C:\Program Files\Git\usr\bin\bash.exe) instead.

2. CMake/Ninja generates object file paths from absolute source file
   paths. On Windows, Ninja converts the drive letter colon (C:) to
   an underscore (C_), producing a path like:
     CMakeFiles/react-native-audio-api.dir/C_/Users/.../audioapi
   which it cannot mkdir, failing with:
     ninja: error: mkdir(...C_/Users/...): No such file or directory
   Fix: convert absolute glob results to relative paths via
   file(RELATIVE_PATH) before passing them to add_library, so Ninja
   creates simple relative object directories with no drive letter.

Fixes software-mansion#784 (Ninja mkdir error on Windows)
Fixes software-mansion#1012 (bash not found on Windows)
@mdydek mdydek added the fix label May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants