-
Notifications
You must be signed in to change notification settings - Fork 24.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0.75-rc.3: autolink should handle failures in rnc/cli config
#45307
Labels
Resolution: PR Submitted
A pull request with a fix has been provided.
Tool: Gradle
Type: New Architecture
Issues and PRs related to new architecture (Fabric/Turbo Modules)
Comments
rnc/cli config
Sounds great to me 👍 Could you send this as a PR @mfazekas and ping me there? |
@cortinico PR #45333 added |
blakef
pushed a commit
that referenced
this issue
Jul 15, 2024
…n zero exit code (#45333) Summary: Fixes: #45307 ## Changelog: [Android] [Fixed] - if `npx react-native-community/cli config` fails or timeouts proper error is shown and built is aborted, instead of leaving and empty autolinking.json During build `npx react-native-community/cli config` is generated into autolinking.json. When command fails, we should error and should not leave and empty `autolinking.json` Pull Request resolved: #45333 Test Plan: Output of the reproducer in #45307 looks like this: ```log android % ./gradlew assembleDebug Starting a Gradle Daemon (subsequent builds will be faster) ERROR: autolinkLibrariesFromCommand: Failed to create /Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/android/build/generated/autolinking/autolinking.json - process npx react-native-community/cli config exited with error code: 126 FAILURE: Build failed with an exception. * Where: Settings file '/Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/android/settings.gradle' line: 3 * What went wrong: A problem occurred evaluating settings 'android'. > ERROR: autolinkLibrariesFromCommand: Failed to create /Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/android/build/generated/autolinking/autolinking.json - process npx react-native-community/cli config exited with error code: 126 * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 10s 8 actionable tasks: 4 executed, 4 up-to-date ``` Output if you modify the package.json to be invalid looks like this: ```log android % ./gradlew assembleDebug ERROR: autolinkLibrariesFromCommand: process npx react-native-community/cli config exited with error code: 1 JSONError: JSON Error in /Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/package.json: 35 | "node": ">=18" 36 | }, > 37 | SOMETHING_NON_JSON | ^ 38 | "packageManager": "[email protected]", 39 | "resolutions": { 40 | "rtn-centered-text": "portal:../RTNCenteredText" Unexpected token "S" (0x53) in JSON at position 1019 while parsing near "...ode\": \">=18\"\n },\n SOMETHING_NON_JSON\n ..." 35 | "node": ">=18" 36 | }, > 37 | SOMETHING_NON_JSON | ^ 38 | "packageManager": "[email protected]", 39 | "resolutions": { 40 | "rtn-centered-text": "portal:../RTNCenteredText" at parseJson (/Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/node_modules/parse-json/index.js:29:21) at loadJson (/Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/node_modules/react-native-community/cli-config/node_modules/cosmiconfig/dist/loaders.js:48:16) at #loadConfiguration (/Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/node_modules/react-native-community/cli-config/node_modules/cosmiconfig/dist/ExplorerSync.js:116:36) at #loadConfigFileWithImports (/Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/node_modules/react-native-community/cli-config/node_modules/cosmiconfig/dist/ExplorerSync.js:87:54) at #readConfiguration (/Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/node_modules/react-native-community/cli-config/node_modules/cosmiconfig/dist/ExplorerSync.js:84:82) at search (/Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/node_modules/react-native-community/cli-config/node_modules/cosmiconfig/dist/ExplorerSync.js:50:63) at emplace (/Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/node_modules/react-native-community/cli-config/node_modules/cosmiconfig/dist/util.js:36:20) at ExplorerSync.search (/Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/node_modules/react-native-community/cli-config/node_modules/cosmiconfig/dist/ExplorerSync.js:78:42) at getUserDefinedOptionsFromMetaConfig (/Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/node_modules/react-native-community/cli-config/node_modules/cosmiconfig/dist/index.js:32:37) at mergeOptionsBase (/Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/node_modules/react-native-community/cli-config/node_modules/cosmiconfig/dist/index.js:60:31) FAILURE: Build failed with an exception. * Where: Settings file '/Users/boga/Work/OSS/RNMBGL/rn-fabric-boolattribute/ReproducerApp/android/settings.gradle' line: 3 * What went wrong: A problem occurred evaluating settings 'android'. > ERROR: autolinkLibrariesFromCommand: process npx react-native-community/cli config exited with error code: 1 * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 2s 8 actionable tasks: 4 executed, 4 up-to-date ``` Reviewed By: cipolleschi Differential Revision: D59582430 Pulled By: cortinico fbshipit-source-id: bedb9563175cc5c46f5af80cf309769e56b803cc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Resolution: PR Submitted
A pull request with a fix has been provided.
Tool: Gradle
Type: New Architecture
Issues and PRs related to new architecture (Fabric/Turbo Modules)
Description
My yarn installation went wrong for some reason and executable permission was missing from rn-cli. Now it's fair that build failed, but it was failing in a cryptic way. Especially since the command mentioned in error message -
react-native config
was working fine.What's wasn't working and was invoked by gradle is
npx @react-native-community/cli config
Also the failure of the commend itself is not printed to grade and an empty autolink.json got created
Code should be logging failure of command and remove output file in such case.
react-native/packages/gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt
Lines 49 to 56 in 8c8c77b
Something simple could be added to then end:
Steps to reproduce
React Native Version
0.75.0-rc.3
Affected Platforms
Runtime - Android, Build - MacOS
Areas
Codegen
Output of
npx react-native info
android % npx react-native config
{
"root": "/private/tmp/TestAL/rn-075-autolink/ReproducerApp",
"reactNativePath": "/private/tmp/TestAL/rn-075-autolink/ReproducerApp/node_modules/react-native",
"reactNativeVersion": "0.75",
...
}
Reproducer
https://github.com/mfazekas/rn-075-autolink
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: