Skip to content

fix(android): run gradlew.bat by its full path on Windows - #2899

Open
tlq5l wants to merge 3 commits into
react-native-community:mainfrom
tlq5l:fix/gradlew-bat-path-2884
Open

tlq5l wants to merge 3 commits into
react-native-community:mainfrom
tlq5l:fix/gradlew-bat-path-2884

Conversation

@tlq5l

@tlq5l tlq5l commented Nov 24, 2026 •

Copy link
Copy Markdown

Summary

build-android, run-android and the --interactive task list now find the Gradle wrapper on Windows when NoDefaultCurrentDirectoryInExePath is set.

Fixes #2884.

They ran the bare name, which cmd then does not look up in the current folder. They now run path.join(sourceDir, 'gradlew.bat'); .\gradlew.bat is not enough, as cross-spawn normalizes it back to gradlew.bat.

Test Plan

Three new tests stub process.platform as win32 and check the command each place runs.

Before/after vs base: 3 of 20 tests fail with base code; with yarn install --frozen-lockfile --ignore-engines && yarn build:ts && yarn build && yarn jest packages/cli-platform-android && yarn lint, all 20 pass with this PR.

Tests (agent-run) at d086057, clean setup (empty HOME, no git config): yarn install --frozen-lockfile --ignore-engines && yarn build:ts && yarn build && yarn jest packages/cli-platform-android && yarn lint, exit 0. Last output line: Done in 11.22s..

Real run (agent-run) on Windows Server 2022 under QEMU, with NoDefaultCurrentDirectoryInExePath=1: the bare gradlew.bat fails with "'gradlew.bat' is not recognized"; the full path runs, in a folder with and without a space.

AI disclosure: this PR was written with an AI coding agent; the test results above come from the agent's runs.

@tlq5l
tlq5l requested a review from cortinico as a code owner November 24, 2026 05:27
cross-spawn normalizes the command for cmd.exe, which turns .\gradlew.bat
back into the bare name gradlew.bat.

Agent: claude
@tlq5l tlq5l changed the title fix(android): run gradlew.bat by its path on Windows fix(android): run gradlew.bat by its full path on Windows Nov 24, 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.

build-android fails on Windows when NoDefaultCurrentDirectoryInExePath is set: 'gradlew.bat' is not recognized

2 participants