android: patch RN settings.gradle.kts /tmp projectDir for Windows - #387
Open
kraenhansen wants to merge 2 commits into
Open
android: patch RN settings.gradle.kts /tmp projectDir for Windows#387kraenhansen wants to merge 2 commits into
kraenhansen wants to merge 2 commits into
Conversation
The Windows unit-test lane failed configuring the React Native build-from-
source composite build:
Configuring project ':packages:react-native' without an existing directory
is not allowed. The configured projectDirectory '...\react-native\tmp'
does not exist
React Native's own settings.gradle.kts declares the intermediate container
projects :packages and :packages:react-native with projectDir = file("/tmp"),
purely to satisfy Gradle 9's rule that every project in a path have an existing
folder. "/tmp" exists on the posix CI hosts but on Windows it is not an
absolute path, so Gradle resolves it to a non-existent <react-native>\tmp and
the build fails before any task runs. This is why only windows-latest was red
while ubuntu and macOS passed.
Add a pnpm patch replacing file("/tmp") with
file(System.getProperty("java.io.tmpdir", "/tmp")): the JVM temp dir is "/tmp"
on posix and %TEMP% on Windows, both of which always exist. Remove the patch
once React Native stops hardcoding "/tmp" upstream.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TVfanKvtyfSsoMgZv3DJtY
meta-codesync Bot
pushed a commit
to react/react-native
that referenced
this pull request
Jul 28, 2026
…ed /tmp (#57706) Summary: `packages/react-native/settings.gradle.kts` declares the intermediate container projects `:packages` and `:packages:react-native` with `projectDir = file("/tmp")`, to satisfy Gradle 9's requirement that every project in a path have an existing folder. `/tmp` exists on posix hosts, but on Windows it is not an absolute path, so Gradle resolves it to a non-existent `<rootDir>\tmp` and build-from-source fails at configuration time: Configuring project ':packages:react-native' without an existing directory is not allowed. Use `System.getProperty("java.io.tmpdir", "/tmp")` instead — the JVM temp dir, which is `/tmp` on posix and `%TEMP%` on Windows, and always exists. ## Changelog [ANDROID] [FIXED] - Use the JVM temp dir instead of a hardcoded `/tmp` for the build-from-source container project dirs, fixing Gradle configuration on Windows Pull Request resolved: #57706 Test Plan: - posix: the resolved dir is unchanged (`/tmp`); build-from-source configures as before. - Windows: resolves to an existing temp dir, so `includeBuild(../node_modules/react-native)` configures successfully instead of erroring. - Downstream evidence: this exact change greened the `windows-latest` Gradle lane in callstackincubator/react-native-node-api#387. Reviewed By: christophpurrer Differential Revision: D113816859 Pulled By: Abbondanzo fbshipit-source-id: 9846dadab9012369dcab26aa05ea3297633acf9f
The upstream fix landed on react-native main as 908872a6 (2026-07-28, react/react-native#57706), after the 0.87 branch cut — so 0.87-stable does not carry it. Record that in the patch comment so the removal gate is a concrete react-native version rather than "once upstream fixes it". Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Targets the
kh/adopt-static-h-node-apibranch (PR #372). Follow-up to #386, which greened ubuntu + macOS but left windows-latest red on a different cause.Root cause
After #386 fixed the
Project.exec()removal, the Windows Gradle build got further and bothgradle.test.tscases failed at configuration time:This is upstream React Native, not our code. RN's own
settings.gradle.kts(used for build-from-source composite builds, which this project requires) declares the intermediate container projects with a throwaway dir:/tmpexists on the posix CI hosts, so ubuntu/macOS pass. On Windows/tmpis not absolute, so Gradle resolves it to a non-existent<react-native>\tmp, and Gradle 9 hard-errors on a missingprojectDirectory— failing before any task runs.Fix
A
pnpm patchon our pinned RN nightly, replacingfile("/tmp")withfile(System.getProperty("java.io.tmpdir", "/tmp"))— the JVM temp dir, which is/tmpon posix and%TEMP%on Windows and always exists.Files:
patches/react-native@0.87.0-nightly-20260529-88857d22f.patchpnpm-workspace.yaml(patchedDependenciesentry)pnpm-lock.yamlScope and tradeoffs — read before merging
This patch is deliberately workspace-only. It is not distributed to consumers of
react-native-node-api.patchedDependenciesinpnpm-workspace.yamlapplies to installs in this repo only. It is not part of the publishedpackages/hosttarball, and it does not apply to a user's app even if they also use pnpm. So merging this fixes our CI, and nothing else.What that means for users, concretely:
react-native-node-apirequires building React Native from source on Android (we need Hermes patched with Node-API — see docs/ANDROID.md). That is exactly the code path this RN bug breaks./tmpcannot build their Android app at all — it fails at Gradle configuration time, before any of our code runs./tmpexists there), so this is a Windows-only user-facing gap.settings.gradle.kts, evaluated during Gradle's settings phase of the composite build. Our Gradle plugin and our npm package are both loaded too late to intervene. The only real fixes are the upstream change, or the user applying an equivalent patch in their own app.Why not distribute it anyway: we'd have to ask every consumer to add a patch for a specific RN version string, which breaks the moment they bump RN, and it would only ever have helped the subset of users who (a) are on Windows and (b) pin the same RN nightly we do. The upstream fix is already merged; carrying a distributable patch would be maintenance for a window that's closing on its own.
Removal gate
The upstream fix is merged: facebook/react-native#57706, landed on
mainas908872a6on 2026-07-28.It landed after the 0.87 branch cut, so
0.87-stabledoes not carry it — 0.87.0 final (currently at rc.4) will still be broken on Windows unless someone cherry-picks it. Revert this patch once we pin a react-native that actually contains908872a6:mainon/after 2026-07-29 (our current pin is0.87.0-nightly-20260529, which predates it), orBumping the pinned nightly past 2026-07-29 would drop the patch outright — but that's a much larger change to land on top of the static_h work in #372, so it's intentionally left out of this PR.
The same condition is recorded as a comment inside the patch itself, so whoever next touches it doesn't have to find this PR.
Test plan
Generated by Claude Code