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 link" adds dependncies multiple times to Android projects when working on a Windows dev environment #13077

Closed
yairk opened this issue Mar 22, 2017 · 2 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@yairk
Copy link

yairk commented Mar 22, 2017

Description

When working on a Windows development environment with git's autocrlf configured as true, then repeatedly running react-native link will repeatedly add the same dependencies to the Android app's MainApplication.java, instead of recognizing that the library has already been linked after the first invocation.

Reproduction

Run react-native link repeatedly on a Windows environment with git's autocrlf configured to true. This will add the dependencies multiple times to the MainApplication.java file. I can provide a sample project if required.

Solution

I suspect the reason is that in react-native/local-cli/link/android/patches/makeBuildPatch.js, the patch value is created with a trailing \n. Later, in react-native/local-cli/link/android/patches/isInstalled.js, the code searches for this pattern in the project's build.gradle. On Windows, this will return -1 because the line ends with \r\n rather than \n. This causes link to apply the patch again.

One way of fixing this is to use Node.JS's os.EOL rather than \n, but I'm too new to react-native to know if it's fine for react-native's build process to depend on NodeJS-specific libraries (rather than pure JavaScript).

Alternatively, isInstalled can trim the line before searching for it. However, the code will still insert the patch with a \n into the patched files (though git will then correct the newlines).

Of course, if I worked with autocrlf set to false on my machine then I wouldn't be having this problem, but this isn't the recommended way to work on Windows - see e.g. the Github documentation.

Additional Information

  • React Native version: 0.42.3.
  • Platform: Android.
  • Development Operating System: Windows.
@yairk yairk mentioned this issue Apr 27, 2017
@hramos
Copy link
Contributor

hramos commented May 25, 2017

We're cutting down on the number of outstanding issues, in order to allow us to focus. I'm closing this issue because it has been open for over 60 days with no activity. If you think it should still be opened let us know why. PRs are always welcome.

@hramos hramos closed this as completed May 25, 2017
@hramos hramos added the Icebox label May 26, 2017
@filipemerker
Copy link

+1

@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants