Skip to content

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

2 participants