Skip to content

android: patch RN settings.gradle.kts /tmp projectDir for Windows#387

Open
kraenhansen wants to merge 1 commit into
kh/adopt-static-h-node-apifrom
claude/windows-gradle9-projectdir
Open

android: patch RN settings.gradle.kts /tmp projectDir for Windows#387
kraenhansen wants to merge 1 commit into
kh/adopt-static-h-node-apifrom
claude/windows-gradle9-projectdir

Conversation

@kraenhansen

Copy link
Copy Markdown
Collaborator

Targets the kh/adopt-static-h-node-api branch (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 both gradle.test.ts cases failed at configuration time:

Configuring project ':packages:react-native' without an existing directory is not allowed.
The configured projectDirectory '...\react-native@0.87...\node_modules\react-native\tmp' does not exist

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:

// Since Gradle 9.0, all the projects in the path must have an existing folder.
project(":packages").projectDir = file("/tmp")
project(":packages:react-native").projectDir = file("/tmp")

/tmp exists on the posix CI hosts, so ubuntu/macOS pass. On Windows /tmp is not absolute, so Gradle resolves it to a non-existent <react-native>\tmp, and Gradle 9 hard-errors on a missing projectDirectory — failing before any task runs.

Fix

There's no fixed RN release to bump to (pinned nightly), so this adds a pnpm patch replacing file("/tmp") with file(System.getProperty("java.io.tmpdir", "/tmp")) — the JVM temp dir, which is /tmp on posix and %TEMP% on Windows and always exists. The patch carries a comment with its removal condition (once RN stops hardcoding /tmp).

Files:

  • patches/react-native@0.87.0-nightly-20260529-88857d22f.patch
  • pnpm-workspace.yaml (patchedDependencies entry)
  • pnpm-lock.yaml

Test plan

The native Android/Windows build isn't runnable on the Linux worker this was authored on, so the cross-platform behaviour is verified by CI on the #372 branch rather than locally. Worth reporting upstream to React Native so the /tmp hardcode is fixed at the source.


Generated by Claude Code

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants