Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Not all linkers respect supportedArchitectures #4323

Closed
2 tasks
Brooooooklyn opened this issue Apr 4, 2022 · 3 comments · Fixed by #4343
Closed
2 tasks

[Bug] Not all linkers respect supportedArchitectures #4323

Brooooooklyn opened this issue Apr 4, 2022 · 3 comments · Fixed by #4343
Labels
bug Something isn't working

Comments

@Brooooooklyn
Copy link
Contributor

  • I'd be willing to implement this feature (contributing guide)
  • This feature is important to have in this repository; a contrib plugin wouldn't do

Describe the user story

I'm using yarn3.2.0 in my NAPI-RS projects, and in the CI test steps I want to install dependencies on host platform and testing the native addons on the qemu Docker images.

Installing dependencies on the host platform has many advantages:

  • It's easy to use actions/cache to cache yarn dependencies.
  • It's faster because the host platform is running on the native CPU arch.

Imagine testing linux-aarch64-musl native addons on ubuntu-latest x64 host, I want to install dependencies in these steps:

  • yarn config set supportedArchitectures.cpu 'arm64'
  • yarn config set supportedArchitectures.libc 'musl'
  • yarn install --immutable --mode=skip-build

With the current version, yarn will throw error in linking step: Error: While persisting /canvas/.yarn/cache/@swc-core-linux-x64-gnu-npm-1.2.163-e0dc2d703e-8.zip/node_modules/@swc/core-linux-x64-gnu/ -> /canvas/node_modules/@swc/core-linux-x64-gnu ENOENT: no such file or directory, scandir '/canvas/.yarn/cache/@swc-core-linux-x64-gnu-npm-1.2.163-e0dc2d703e-8.zip/node_modules/@swc/core-linux-x64-gnu'

If set CPU and libc with current:

  • yarn config set supportedArchitectures.cpu --json '["arm64", "current"]'
  • yarn config set supportedArchitectures.libc --json '["musl", "current"]'
  • yarn install --immutable --mode=skip-build

Only packages satisfied with the current platform will be preserved, ls -la @swc:

root@6d7dbe3dd415:/canvas# ls node_modules/@swc
core  core-linux-x64-gnu

Describe the solution you'd like

I think in linking steps should only preserve the packages satisfied with supportedArchitectures but not the current platform.

Describe the drawbacks of your solution

Only preserve the packages satisfied with supportedArchitectures.

Describe alternatives you've considered

Add a flag to specify this behavior?

@Brooooooklyn Brooooooklyn added the enhancement New feature or request label Apr 4, 2022
@merceyz
Copy link
Member

merceyz commented Apr 11, 2022

We forgot to update the node-modules linker in #3575 to support supportedArchitectures so this is a bug.

@merceyz merceyz added bug Something isn't working and removed enhancement New feature or request labels Apr 11, 2022
@merceyz merceyz changed the title Add an option to preserve optionalDependencies which are different cpu os and libc from current platform [Bug] Not all linkers respect supportedArchitectures Apr 11, 2022
@merceyz
Copy link
Member

merceyz commented Apr 12, 2022

Fix has been released as 4.0.0-rc.2

yarn set version canary

@merceyz
Copy link
Member

merceyz commented May 13, 2022

The fix has been backported and released in v3.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants