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.
This commit is contained in:
Jamil
2025-07-27 23:42:21 -04:00
committed by GitHub
parent bfa77bf7fc
commit 589d2bbf4b

View File

@@ -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",
)
}
}