Skip to content

Conversation

@szymonrybczak
Copy link
Contributor

Summary:

While linking CLI to React Native project using Yarn v3 (which is default for new project initialised starting from 0.74) I hit this problem:

➤ YN0000: ┌ Link step
➤ YN0001: │ Error: Assertion failed: Writing attempt prevented to /Users/szymonrybczak/development/cli/packages/cli/node_modules/ws which is outside project root: /Users/szymonrybczak/development/tmp/RC4

I checked with NM_DEBUG_LEVEL=2 yarn what is the source of this problem, and it turns out that ws package has different version across cli-server-api and react-native package. In this PR I've updated version of ws package to align with cli-server-api.

Changelog:

[INTERNAL] [CHANGED] - Upgrade ws package to ^7.5.1

Test Plan:

  1. Create app with npx react-native@next init RN0740RC5 --version 0.74.0-rc.5 (ensure that you have Yarn v3 inside your project)
  2. Follow CONTRIBUTING.md guide inside React Native Community CLI
  3. yarn link ~/path/to/cli --all should pass without any issues.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner labels Mar 28, 2024
@github-actions
Copy link

Warnings
⚠️ 🔒 package.json - Changes were made to package.json. This will require a manual import by a Facebook employee.

Generated by 🚫 dangerJS against 1892dfa

@szymonrybczak
Copy link
Contributor Author

After merging this Pull Request, it should be backported to 0.74.

@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 Mar 28, 2024
@szymonrybczak szymonrybczak changed the title chore: upgrade ws package ^7.5.1 chore: upgrade ws package to ^7.5.1 Mar 28, 2024
@facebook-github-bot
Copy link
Contributor

@huntie has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 18,483,520 -4,101
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 21,856,632 +6
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 2af1da4
Branch: main

@robhogan
Copy link
Contributor

This feels like a workaround for a yarn link problem rather than anything users would encounter. Do you know why it can't handle different versions of a dependency between the host and linked project?

@szymonrybczak
Copy link
Contributor Author

Do you know why it can't handle different versions of a dependency between the host and linked project?

Yarn v3 uses portal:/ protocol for linking dependencies by default, and that's root cause of the whole problem. If you run yarn link ~/path/to/cli --all it will add to the project's resolutions field relevant entries, if you change portal to link in package.json it will work.

I assume that since we're using nodeLinker: node-modules we are in different state, where Yarn v3 was designed in first place was designed to use PnP and we're using other linker it causes this kind of problems that we can't have different versions of packages when using portal:/ protocol.

@szymonrybczak
Copy link
Contributor Author

Moved to: react-native-community/cli#2355

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: Callstack Partner: Callstack 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.

4 participants