-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Adds support for running native binaries without JS intermediaries #5508
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably we'll need to do this for the following locations as well:
berry/packages/yarnpkg-core/sources/scriptUtils.ts
Lines 491 to 495 in ca47575
await Promise.all( | |
Array.from(await getWorkspaceAccessibleBinaries(workspace), ([binaryName, [, binaryPath]]) => | |
makePathWrapper(binFolder, toFilename(binaryName), process.execPath, [binaryPath]), | |
), | |
); |
berry/packages/yarnpkg-core/sources/scriptUtils.ts
Lines 544 to 548 in ca47575
await Promise.all( | |
Array.from(await getPackageAccessibleBinaries(locator, {project}), ([binaryName, [, binaryPath]]) => | |
makePathWrapper(binFolder, toFilename(binaryName), process.execPath, [binaryPath]), | |
), | |
); |
berry/packages/yarnpkg-core/sources/scriptUtils.ts
Lines 741 to 745 in ca47575
await Promise.all( | |
Array.from(packageAccessibleBinaries!, ([binaryName, [, binaryPath]]) => | |
makePathWrapper(env.BERRY_BIN_FOLDER as PortablePath, toFilename(binaryName), process.execPath, [binaryPath]), | |
), | |
); |
There are some issues that this probably fixes (for example #882), could you check and link to them so they're closed? |
Not sure about this PR, but from the title it might fix some turborepo hacks: https://github.com/vercel/turbo/blob/main/packages/turbo/install.js#L190 So it might also relate to |
I've tried
|
This fix is only about native binaries. From your logs, expo is a shellscripts, which aren't allowed in |
Will the changes be also added to yarn 3? |
…5508) **What's the problem this PR addresses?** Yarn currently cannot run native binaries without going through a JS jumper script. Other package managers don't have this restriction, and it makes the `yarn run` overhead worse on some scripts for little reasons - or doesn't work at all when packages don't use jumper scripts. **How did you fix it?** Two mechanisms are used: - First we check for the binary extension - Then we check its magic number If one of the two match a predetermined list, the binary is spawned without going through Node. This ensures that this logic is called only when the binary is truly a native binary, and will not affect the behaviour of other existing scripts. **Checklist** <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [x] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [x] I will check that all automated PR checks pass before the PR gets reviewed.
Yes, I've backported it now so it will be in the next release. |
What's the problem this PR addresses?
Yarn currently cannot run native binaries without going through a JS jumper script. Other package managers don't have this restriction, and it makes the
yarn run
overhead worse on some scripts for little reasons - or doesn't work at all when packages don't use jumper scripts.Fixes #882
How did you fix it?
Two mechanisms are used:
If one of the two match a predetermined list, the binary is spawned without going through Node. This ensures that this logic is called only when the binary is truly a native binary, and will not affect the behaviour of other existing scripts.
Checklist