fix(pods): Fix invalid react-native/../react-native resolution for aliases - #9592
Merged
tjzel merged 4 commits intoJun 8, 2026
Conversation
m-bert
added a commit
to software-mansion/react-native-gesture-handler
that referenced
this pull request
Jun 8, 2026
…aliases (#4232) ## Description Related: software-mansion/react-native-reanimated#9592 (same fix for `react-native-reanimated` and `react-native-worklets`) The pod script attempts to resolve `react-native/package.json` to get to the `version` and perform a version check. It however performs a redundant `react-native/../react-native` resolution i.e. it essentially performs `path.dirname(require.resolve('react-native/package.json'))` (correct), but then joins this with `${dir}/..`, then re-joins this with `react-native`. Re-entering the `react-native` directory can be invalid in case of symlinks in the `node_modules` structure. 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 named `react-native-tvos` and not `react-native`. The also applies to local `link:` dependency specifiers. Essentially, the directory name `react-native` is unnecessarily enforced. This would lead to a cryptic `file: no implicit conversion of nil into String.` error ## Test plan - Existing `pod install` in working projects should continue passing unchanged - https://github.com/kitten/douglowder--with-monorepo-tv-test/tree/init-pnpm - `pnpm i` then in `apps/tv` run `pnpm prebuild` (which runs `pod install`) --------- Co-authored-by: Michał Bert <63123542+m-bert@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the CocoaPods Ruby helper scripts for Reanimated and Worklets to resolve the React Native installation directory directly from require.resolve('react-native/package.json'), avoiding the redundant react-native/../react-native path reconstruction that can break when react-native is provided via aliases/symlinks (e.g., npm:react-native-tvos, link:).
Changes:
- Resolve
react-native/package.jsonand use its containing directory as the React Native root (instead of deriving anode_modulesdir and re-joiningreact-native). - Adjust ReactCommon path construction to be rooted at the resolved React Native directory.
- Rename config key from
:react_native_node_modules_dirto:react_native_dirin both scripts.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/react-native-worklets/scripts/worklets_utils.rb | Switches React Native path resolution to use the resolved RN package directory directly (symlink-safe). |
| packages/react-native-reanimated/scripts/reanimated_utils.rb | Same React Native path resolution adjustment for Reanimated’s pod utilities. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merged
via the queue into
software-mansion:main
with commit Jun 8, 2026
71647bf
6 of 7 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Related: software-mansion/react-native-gesture-handler#4232 (same fix for
react-native-gesture-handler)The pod scripts attempt 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)