facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
117.16k stars 24.08k forks source link

Add support for Gradle Configuration Cache #45154

Open pvdmde opened 2 weeks ago

pvdmde commented 2 weeks ago

Description

Using Gradle 8.2 or newer with stable config cache support, enabling it with org.gradle.configuration-cache=true I'm getting this error:

4 problems were found storing the configuration cache, 2 of which seem unique.
- Script '/Users/..../node_modules/@react-native-community/cli-platform-android/native_modules.gradle': external process started 'node -e try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}'
  See https://docs.gradle.org/8.2.1/userguide/configuration_cache.html#config_cache:requirements:external_processes
org.gradle.api.InvalidUserCodeException: Starting an external process 'node -e try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}' during configuration time is unsupported.
    at org.gradle.configurationcache.initialization.DefaultConfigurationCacheProblemsListener.onExternalProcessStarted(ConfigurationCacheProblemsListener.kt:117)
    at org.gradle.configurationcache.InstrumentedInputAccessListener.externalProcessStarted(InstrumentedInputAccessListener.kt:110)
    at org.gradle.internal.classpath.Instrumented.externalProcessStarted(Instrumented.java:501)

Currently we're wasting 30s to 1 minute on configuration step every time we build, also locally. I reported it almost a year ago in https://github.com/react-native-community/cli/issues/2058, now it being closed there I should recreate it here.

Steps to reproduce

Using Gradle 8.2 or newer with stable config cache support, enabling it with org.gradle.configuration-cache=true I'm getting this error:

React Native Version

0.74.0

Affected Platforms

Build - MacOS

Output of npx react-native info

irrelevant

Stacktrace or Logs

4 problems were found storing the configuration cache, 2 of which seem unique.
- Script '/Users/..../node_modules/@react-native-community/cli-platform-android/native_modules.gradle': external process started 'node -e try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}'
  See https://docs.gradle.org/8.2.1/userguide/configuration_cache.html#config_cache:requirements:external_processes
org.gradle.api.InvalidUserCodeException: Starting an external process 'node -e try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}' during configuration time is unsupported.
    at org.gradle.configurationcache.initialization.DefaultConfigurationCacheProblemsListener.onExternalProcessStarted(ConfigurationCacheProblemsListener.kt:117)
    at org.gradle.configurationcache.InstrumentedInputAccessListener.externalProcessStarted(InstrumentedInputAccessListener.kt:110)
    at org.gradle.internal.classpath.Instrumented.externalProcessStarted(Instrumented.java:501)


### Reproducer

irrelevant, issue is clear in the description

### Screenshots and Videos

_No response_
github-actions[bot] commented 2 weeks ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
github-actions[bot] commented 2 weeks ago
:warning: Newer Version of React Native is Available!
:information_source: You are on a supported minor version, but it looks like there's a newer patch available - 0.74.2. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
cortinico commented 2 weeks ago

Yup this is a known issue. I believe that 0.75 should bring support for Gradle Configuration cache but I need a bit more time testing it.

I'll provide more updates on this issue once I have them