fix(pods): Fix invalid react-native/../react-native resolution for aliases#4232
fix(pods): Fix invalid react-native/../react-native resolution for aliases#4232kitten wants to merge 2 commits into
react-native/../react-native resolution for aliases#4232Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates React Native package.json discovery logic in the gesture handler CocoaPods/Ruby utilities to resolve the React Native directory more directly and adjust fallback behavior.
Changes:
- Change
try_to_parse_react_native_package_jsonto accept a React Native directory (instead of node_modules root) and readpackage.jsonfrom that directory. - Update
get_react_native_minor_versionto derive the React Native directory viarequire.resolve('react-native/package.json')and adjust the ENV fallback path.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @kitten! Is this problem specific to monorepo? Today I used newly created react-native-tvos to investigate our buttons and I didn't encounter any problems with doing
Unfortunately, after this change |
|
I've renamed them. I assume we'd have to then do something similar in the other script in the related PRs, but the naming there is suspiciously generic. I'll leave it up to the review there though
No, not necessarily. For the TvOS case, as mentioned, it's triggerable in isolated installations, since we try to re-enter the react-native folder that's not named 'react-native' Generically, this applies to any case where we resolve through a symlink where the folder of the resolved package for react-native isn't called react-native, which can likely be triggered in other ways, like with |
Description
Related: software-mansion/react-native-reanimated#9592 (same fix for
react-native-reanimatedandreact-native-worklets)The pod script attempts to resolve
react-native/package.jsonto get to theversionand perform a version check. It however performs a redundantreact-native/../react-nativeresolution i.e. it essentially performspath.dirname(require.resolve('react-native/package.json'))(correct), but then joins this with${dir}/.., then re-joins this withreact-native.Re-entering the
react-nativedirectory can be invalid in case of symlinks in thenode_modulesstructure. The easiest way to reproduce an issue is to use react-native-tvos's pattern of aliasing"react-native": "npm:react-native-tvos@x.x.x". With isolated dependencies this will point a symlink at a directory that's namedreact-native-tvosand notreact-native. The also applies to locallink:dependency specifiers. Essentially, the directory namereact-nativeis unnecessarily enforced.This would lead to a cryptic
file: no implicit conversion of nil into String.errorTest plan
pod installin working projects should continue passing unchangedpnpm ithen inapps/tvrunpnpm prebuild(which runspod install)