Skip to content
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

react-native-community-cli in 0.61+ breaks existing working builds #28768

Closed
vladp opened this issue Apr 27, 2020 · 7 comments
Closed

react-native-community-cli in 0.61+ breaks existing working builds #28768

vladp opened this issue Apr 27, 2020 · 7 comments
Labels
Needs: Triage 🔍 Platform: Linux Building on Linux. Resolution: Locked This issue was locked by the bot.

Comments

@vladp
Copy link

vladp commented Apr 27, 2020

Description

RN 0.60+ made usage of @react-native-community/cli required (at least for Android).

in 0.61 @react-native-community/cli broke application builds that do not comply with their new relative-directory structure requirement (which is also not well documented)

This a regression of capabilities offered by previous releases of RN.

If one has:

  project/FRONTEND/androidapps/app1
  project/FRONTEND/rn.common/ <--  root for JS (eg node_modules, package.json etc)

This directory structure no longer works with 0.61+ React native releases.

The new CLI tool ignores react-native Android project template documentation,
when it comes to specifying the directory 'where package.json lives':

https://github.com/facebook/react-native/blob/master/template/android/app/build.gradle


project.ext.react = [
// the root of your project, i.e. where "package.json" lives
//   root: "../../",
]

And, instead, @react-native-community/cli tries to infer where package.json lives by using nodeJS module resolution guessing (which is done simply by invoking node in the directory root project direction of Android app, and having nodeJS to search for node_modules .. .which it cannot find, in the above described case).

The issue was reported in October 2019.
react-native-community/cli#804
Now it is marked as closed, but the issue is not fixed (and is not re-opened).

There is no way to disable autolinking feature in the new CLI (which is where the regression was introduced), so no way to workaround this regression.

React Native version:

Please note, the issue first appeared in RN 0.60, reported but not fixed since October 2019.

So this bug report requests that RN makes necessary changes to make @react-native-community/cli optional.

[v@host rn.common]$ ./node_modules/.bin/react-native info
info Fetching system and libraries information...
System:
OS: Linux 5.5 Fedora 31 (Thirty One) 31 (Thirty One)
CPU: (4) x64 Intel(R) Core(TM) i7 CPU
Memory: 511.33 MB / 11.51 GB
Shell: 5.0.11 - /bin/bash
Binaries:
Node: 12.16.1 - /bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.4 - /bin/npm
Watchman: Not Found
SDKs:
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Languages:
Java: javac 14 - /bin/javac
Python: 3.7.6 - /bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: ^0.62 => 0.62.2
npmGlobalPackages:
react-native: Not Found
[v@host rn.common]$


Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.
Setup an android project such as

  project/FRONTEND/androidapps/app1
  project/FRONTEND/rn.common/ <--  root for JS (eg node_modules, package.json etc)

Expected Results

see the detailed example, with this regression -- the build on Android fails
react-native-community/cli#804

@stale
Copy link

stale bot commented Jul 26, 2020

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jul 26, 2020
@vladp
Copy link
Author

vladp commented Jul 30, 2020

This issue still requires attention. It is not resolved.
Without modifying manually the react-native-community-cli package, I cannot get it to build.
I think the design issue, if I may call it that, is that the cli since 0.61+ requires modification to
settings.gradle
eg:
apply from: file("${myRnAppRootDir_abs}/node_modules/@react-native-community/cli

The above inclusion is ok, however the CLI's code does not understand that
node_modules directory is at ${myRnAppRootDir_abs}/node_modules/
And, instead, it tries to find it in the android's project root or ../
But it is not there, the CLI team removed any ability to specify where the node_modules is.

Without node_modules directory being found, the cli.js code fails.
Which causes the whole andorid build to fail.

It is not clear to me whether the CLI community team feels that the previously working functionality in this area could be broken, or they feel that they have fixed it. They stopped replying to previously referenced bug report.

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jul 30, 2020
@vladp
Copy link
Author

vladp commented Aug 28, 2020

Hello,
this issue is not resolved and requires attention.
the react-native-community-cli does not allow node_modules directory of the React native side to be arbitrary.
That functionality was available before react-native-cli in 0.61
This is not a Linux specific problem, so not sure why linux tag is added to the issue.

@safaiyeh
Copy link
Contributor

Hi @vladp thanks for the issue and sorry that you have problems. This would be more appropriate filing with the CLI team. React Native core will have CLI as a dependency.

If you want to propose a new implementation, you can do so here https://github.com/react-native-community/discussions-and-proposals

@safaiyeh
Copy link
Contributor

Closing, but please create an issue with CLI to get this resolved

@vladp
Copy link
Author

vladp commented Aug 28, 2020

@safaiyeh I had created this issue with CLI, october 2019.
That project is not solving it.

Since RN had adapted CLI as the only method of building apps, and the CLI broke previously available functionality -- I am asking the RN team to look into this.

@bendoylezazzle
Copy link

I would second that request. I was counting on a resolution here to accommodate our project structure. Without a fix, I haven't been able to upgrade RN in months while the iOS branch drifts further and further away.

@facebook facebook locked as resolved and limited conversation to collaborators Oct 1, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Triage 🔍 Platform: Linux Building on Linux. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants