From 589d2bbf4b737422c4a5cd8fd15b3fd4602dec85 Mon Sep 17 00:00:00 2001 From: Jamil Date: Sun, 27 Jul 2025 23:42:21 -0400 Subject: [PATCH] fix(android): spawn shell to cargo (#10024) Unfortunately this seems to be a race condition with read or setting the path properly for this exec block. I've verified `cargo` is in the PATH, and have tried this on a fresh Mac with Android Studio (latest release version). Spawning cargo from `sh -c` fixes the issue. --- kotlin/android/app/build.gradle.kts | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/kotlin/android/app/build.gradle.kts b/kotlin/android/app/build.gradle.kts index 3621173b0..965cc3840 100644 --- a/kotlin/android/app/build.gradle.kts +++ b/kotlin/android/app/build.gradle.kts @@ -279,23 +279,12 @@ val generateUniffiBindings = doLast { // Execute uniffi-bindgen command from the rust directory project.exec { - // Set working directory to the rust directory which is outside the gradle project - workingDir(rustDir) - - // Build the command + // Spawn a shell to run the command; fixes PATH race conditions that can cause + // the cargo executable to not be found even though it is in the PATH. commandLine( - "cargo", - "run", - "--bin", - "uniffi-bindgen", - "generate", - "--library", - "--language", - "kotlin", - input.asFile, - "--out-dir", - outDir.asFile, - "--no-format", + "sh", + "-c", + "cd ${rustDir.asFile} && cargo run --bin uniffi-bindgen generate --library --language kotlin ${input.asFile} --out-dir ${outDir.asFile} --no-format", ) } }