question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Execution failed for task ':react-native-gesture-handler:buildCodegenCLI' + Building with Monorepo

See original GitHub issue

Description

I can’t seem to build react-native-gesture-handler with my monorepo setup. I get the following error:

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':react-native-gesture-handler:buildCodegenCLI'.
> A problem occurred starting process 'command '/Users/redacted/Desktop/Git_Repo/janus/packages/testapp/node_modules/react-native-codegen/scripts/oss/build.sh''

Looking at my workspace, all the packages are in the node-modules on the root folder. However, codegen CLI is looking for the scripts in the workspace node_modules folder instead of the root node_modules. See image below:

image

Steps to reproduce

  1. Configure a mono repo with workspaces
  2. Use react-native-gesture-handler in one of the workspaces
  3. Build the project

Snack or a link to a repository

Private Repo

Gesture Handler version

2.7.1

React Native version

0.70.4

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

Android emulator

Device model

No response

Acknowledgements

Yes

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
j-piaseckicommented, Nov 9, 2022

This seems to be more of a problem with the codegen itself. The code snippet you’ve highlighted is kind of problematic, but it would fail only in cases where react-native-gesture-handler is higher in the directory structure than react-native itself, which doesn’t seem to be the case here.

In case you’re using a custom setup, you are able to set the paths to relevant packages in your build.gradle like so:

react {
    reactNativeDir = rootProject.file("../../../node_modules/react-native/")
    codegenDir = rootProject.file("../../../node_modules/react-native-codegen/")
}

The problem with that is the fact that React Gradle Plugin is also used by the libraries on the new architecture in order to trigger codegen. Because of this, the custom paths are only applied to the root project instead of all projects using the plugin. If all your packages are on the same level, you could use something like this:

project.pluginManager.withPlugin("com.facebook.react") {
    react {
        reactNativeDir = rootProject.file("../../../node_modules/react-native/")
        codegenDir = rootProject.file("../../../node_modules/react-native-codegen/")
    }
}

to set the same paths for all projects using the plugin. Otherwise you may need to take a more granular approach and set the paths per package depending on whether it’s being hoisted or not.

0reactions
j-piaseckicommented, Nov 16, 2022

No problem, great to see that you were able to solve the problem. I’ll close the issue since you’ve resolved the problems with codegen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

EAS build in monorepo failure (Failed to construct transformer ...
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings 1 actionable task: 1 executed Error: Gradle ...
Read more >
Conditional build of subproject within a monorepo depending ...
You probably want to test and build just frontend if no files ... A Task in a Pipeline to be executed only if...
Read more >
The Case for Monorepos: A sane Workspace Setup (Part 2)
Learn how to setup dev tooling in a monorepo, run tasks efficiently, ... would simply not build or produce an error at runtime,...
Read more >
A Guide to Monorepos for Front-end Code - Toptal
With yarn workspaces (and by extension, Lerna) it's the same: executing a build from the monorepo/workspace root should trigger package-b's build script first ......
Read more >
What is monorepo? (and should you use it?) - Semaphore CI
“Having all the code in one repository helped us reduce the feedback loop [in our build systems].” For Pinterest, a monorepo layout provided...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found