Skip to content

[ios] Resolve use_react_native!(path) param in react_native_pods.rb from Pathname.pwd#54948

Closed
kitten wants to merge 1 commit intofacebook:mainfrom
kitten:@kitten/fix/pods-use-react-native-absolute-path
Closed

[ios] Resolve use_react_native!(path) param in react_native_pods.rb from Pathname.pwd#54948
kitten wants to merge 1 commit intofacebook:mainfrom
kitten:@kitten/fix/pods-use-react-native-absolute-path

Conversation

@kitten
Copy link
Contributor

@kitten kitten commented Dec 19, 2025

Summary:

Note

This is a bit of a speculative fix that's based on trying to get a bare project with react-native-macos to link directly against it in an isolated installation, which makes passing path set to require.resolve('react-native-macos/package.json') more convenient than constructing a relative path first.

The path argument in react_native_pods.rb is not resolved but instead later joined using File.join(relative_path_from_current, path). This doesn't actually resolve the path, meaning, if path is absolute it's appended to this first relative path.

Instead, we should use Pathname#join and join the path to the pathname, guaranteeing it to be absolute, then construct relative paths (for the prefix) using relative_path_from against the installation root.

If we don't do this, the absolute path gets treated as a relative path (e.g. ./Users), which leads to errors such as:

[!] Invalid Podfile file: Couldn't find the React Native package.json file at ./Users/phil/git/expo/expo-pnpm/packages/expo/package.json.

Since absolute paths are unambiguous the change should be safe.

Changelog:

[IOS] Allow absolute react-native paths to be passed to use_react_native! in project podfiles

Test Plan:

This can be replicated by replacing path in the use_react_native call with an absolute resolution and running pod install after, for example:

    use_react_native!(
      :path => File.dirname(`node --print "require.resolve('react-native/package.json')"`),
      :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
      # An absolute path to your application root.
      :app_path => "#{Pod::Config.instance.installation_root}/..",
    )

Usually, the path argument gets resolved from the react-native-config via config[:reactNativePath]. However, this makes the implicit assumption that use_native_modules! has already converted this to a relative path.

The `path` argument in `react_native_pods.rb` is not resolved but
instead later joined using `File.join(relative_path_from_current,
path)`. This doesn't actually resolve the path, meaning, if `path` is
absolute it's appended to this first relative path.

Instead, we should use `Pathname#join` and join the path to the
pathname, guaranteeing it to be absolute, then construct relative paths
(for the prefix) using `relative_path_from` against the installation
root.
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 19, 2025
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Dec 19, 2025
@kitten kitten changed the title [ios] Resolve use_react_native!(path) param in reacft_native_pods.rb from Pathname.pwd [ios] Resolve use_react_native!(path) param in react_native_pods.rb from Pathname.pwd Jan 5, 2026
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@meta-codesync
Copy link

meta-codesync bot commented Jan 7, 2026

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D90261384.

Copy link
Contributor

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

Review automatically exported from Phabricator review in Meta.

@meta-codesync meta-codesync bot closed this in 33641f0 Jan 14, 2026
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @kitten in 33641f0

When will my fix make it into a release? | How to file a pick request?

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jan 14, 2026
@meta-codesync
Copy link

meta-codesync bot commented Jan 14, 2026

@cipolleschi merged this pull request in 33641f0.

meta-codesync bot pushed a commit that referenced this pull request Jan 19, 2026
Summary:
This is a fix for a regression in #54948 found by Kudo. Passing an absolute path for `react_native_path` was non-functional before and the change was meant to fix this.

This however used `Pathname.pwd.join(path)` since I assumed that'd be the intention for a relative path. However, my assumption was that `pod install` would only ever be run in the installation root and hence be equivalent to `Pod::Config.instance.installation_root` most of the time.

This broke: `pod install --project-directory ios` (and the likes), since I wasn't aware of the `--project-directory` argument before.

To fix this, we should construct the absolute path and join from `Pod::Config.instance.installation_root` as well.

**Note to self:** Needs a pick into `0.84.0` due to being a regression (will file a pick request after this is merged)

## Changelog:

[IOS] [FIXED] Regression from #54948 preventing `pod install --project-directory` from working properly

Pull Request resolved: #55204

Test Plan: - Run `pod install` in `rn-tester` to validate

Reviewed By: vzaidman

Differential Revision: D90870064

Pulled By: cipolleschi

fbshipit-source-id: 4a7bc0320afda29373791f206b31e57ae48b0b8c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants