Skip to content

fix(pods): Fix invalid react-native/../react-native resolution for aliases - #9592

Merged
tjzel merged 4 commits into
software-mansion:mainfrom
kitten:@kitten/fix/react-native-alias-name-resolution
Jun 8, 2026
Merged

fix(pods): Fix invalid react-native/../react-native resolution for aliases#9592
tjzel merged 4 commits into
software-mansion:mainfrom
kitten:@kitten/fix/react-native-alias-name-resolution

Conversation

@kitten

@kitten kitten commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

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.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

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>

@tjzel tjzel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.json and use its containing directory as the React Native root (instead of deriving a node_modules dir and re-joining react-native).
  • Adjust ReactCommon path construction to be rooted at the resolved React Native directory.
  • Rename config key from :react_native_node_modules_dir to :react_native_dir in 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.

Comment thread packages/react-native-reanimated/scripts/reanimated_utils.rb Outdated
Comment thread packages/react-native-worklets/scripts/worklets_utils.rb Outdated

@tjzel tjzel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@tjzel
tjzel added this pull request to the merge queue Jun 8, 2026
Merged via the queue into software-mansion:main with commit 71647bf Jun 8, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants