-
Notifications
You must be signed in to change notification settings - Fork 905
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
autoLinking doesn't work with monorepo #537
Comments
Did you adjust the root? https://github.com/react-native-community/cli/blob/master/docs/autolinking.md#custom-root-monorepos |
@thymikee root/
node_modules/
react-native/
react-native-touchable-ripple/ # this is the link forlder by yarn
ios/
RNRippleView.xcodeproj
RNRippleView.podspec
...
packages/
react-native-touchable-ripple/
ios/
RNRippleView.xcodeproj
RNRippleView.podspec it work well with "@react-native-community/cli-platform-ios": "2.1.1", |
@yozman oh, that's good to know. Would you like to give it a shot and fix it? :) |
cc @maciejsimka |
I'm experiencing this issue as well. @yozman What is the temporary fix you are using? |
@sm1th you can use Yarn resolutions: https://yarnpkg.com/lang/en/docs/selective-version-resolutions/ and pin |
@thymikee TIL, thanks! |
* fix: remove reliance on `node_modules` in paths to podspecs Previous implementation assumed `node_modules` being somewhere in the path to podspec file and relied on it to create relative path, which broke monorepos (since `config` lists real filepaths instead of, as I assumed previously, symlinks). New implementation subtracts project root path from absolute path to podspec file for the purpose of generating relative path. Resolves #537 * fix: take into account deeper nesting of podspec file * chore: update tests * refactor: replace `partition` with `split` * fallback to empty string when split.last returns nil
Is this fix included in react-native 0.60.4? |
@sm1th it's in the range, here's how to update the |
I followed the upgrade instructions but I'm still having trouble linking a monorepo.
react-native.config.js: module.exports = {
dependencies: {
'my-package': {
root: '/Users/joshua/Projects/myProject/myPackageDir',
},
},
};
|
Are you able to prepare a repro we could download and test? |
Sure, please see my branch here.
I figured out why this structure breaks the native_modules script: If I have
and
then line 59 will return
since the split does nothing. So in the next statement, line 61,
becomes
and of course there's no podspec file there. |
Also having this issue with Android: running the
For context, running the same command in the folder containing the app produces this:
I'm inclined to think this might be an issue with the |
@koredefashokun can you try the latest cli? |
@thymikee Just confirmed that the latest CLI gives the same error. Was able to get the stacktrace by running the command directly. I can share that if it would be useful as well. |
not sure if this is related or not but react-native is showing the following warning in a monorepo
it looks like it is trying to autolinking a package in a yarn workspaces we have like this:
I've created a module.exports = {
project: {
ios: {},
android: {},
},
assets: [],
}; to avoid this warning |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I am facing autolink issue in android with monorepo. ReactNative version: 0.60.4 If we run "yarn workspace mobile react-native config" in the root, The output is ok and the project details are filled. If we run "react-native config" in root then the project details are not filled. When we execute "yarn workspace mobile react-native run-android" I am getting the following error:
This is same as the problem reported by @koredefashokun . Can you please let me know how to resolve this issue. |
What if you tell the CLI where the project is, resolving from the root? // react-native.config.js
module.exports = {
project: {
android: {
sourceDir: './mobile/android',
},
},
}; See: https://github.com/react-native-community/cli/blob/master/docs/projects.md |
@thymikee I tried setting sourceDir in react-native.config.js. But still the issue is same. https://github.com/learnyst/monorepo.git. This is the minimal reproducible demo.
@thymikee please let me know if I need to try any other solution. thanks |
@thymikee any solutions? |
Ok, I've found the issue (at least one of them). Our config resolution relies on
module.exports = {
project: {
android: {
sourceDir: './packages/mobile/android',
},
},
};
--- a/package.json
+++ b/package.json
@@ -6,5 +6,9 @@
"packages/*"
],
"nohoist": []
+ },
+ "dependencies": {
+ "react-native": "*",
+ "@react-native-community/netinfo": "*"
} While on it, how do you usually expect the packages in a monorepo to work? Is it running from the root, or from the package folder? Or maybe both, depending on the use case? |
@thymikee I usually expect running commands in the packages to work from the package folder, but also in the root, via scripts added in the package folder's Having to manually create a |
Yea, that's understandable. We'll work on making easier to integrate. |
When I pod install, the dependencies modules detect only works without using |
I came across this today on iOS for local packages in a monorepo, this is how I got around it, not sure if it works for everyone elses cases but let me know as I can send a PR: #550 (comment) As a side note as well, the change in that PR should probably be using |
@Salakar we explicitly avoid resolving full path, because it's saved in a |
@thymikee ah that makes sense. Not sure it can be avoided with symlinks though as they resolve to the full path as far as I can tell, which is what's causing the issue I think |
Previous implementation made assumption that path to podspec contains path to project root, which is not always the case, for example in monorepos. This caused incorrect generation of podspec path, since in that case it would return absolute podspec path prepended with root path. Used `pathname` class method `relative_path_from` to avoid this issue. Resolves #537
I'm trying to upgrade from react-native 0.59 to 0.61 and having the exact same issue on android:
Although this comment does seem to fix this specific issue, it installs the react-native app inside Any other solution available/coming to this repo? CLI version is v3 alpha 2. |
I have the same issue @brunolemos. I would appreciate any solution that does not involve me to install |
@Esemesek would you find some time to dig it? I'm pretty swamped for the next few weeks, so can't commit to that unfortunately |
Should we open a new issue? If not, please reopen this one. |
Let's open a new one please, this issue tries to handle too many cases and platforms. |
Ok, opened #655. |
I am going to look into this right now and resolve some of the confusion around |
Sorry for the late response. Can confirm everything is now working. Auto-linking in a monorepo is working well for https://github.com/invertase/react-native-firebase - though admittedly it's not using a custom root or anything which I think is the case on some of the other issues here. |
Environment
Description
I have a project use monorepo with yarn workspace feature.
it's fail when I
cd ios && pod install
.then I run
react-native config
Details
I guess this comes with this commit c9aec25
cli/packages/platform-ios/native_modules.rb
Lines 45 to 49 in c9aec25
for podspec
RNRippleView
at #L46absolute_podspec_path
is/Users/flyboy/.dee/yozman/yoboto-app/packages/react-native-touchable-ripple/RNRippleView.podspec
.it's already relative_path and doesn't contain character
node_modules
.so
relative_podspec_path
at #L47 will be not correct.Reproducible Demo
The text was updated successfully, but these errors were encountered: