Skip to content

Conversation

@itsananderson
Copy link
Member

This PR updates build-tools to use Yarn 4, following the instructions from @MarshallOfSound

Since the build-tools repo is a bit different from others in the Electron ecosystem, testing these changes is slightly more challenging.

I pushed a separate yarn-4-auto-update branch to my fork, which modified the auto-update functionality to pull from that same yarn-4-auto-update branch. That way I could test the auto-update functionality and make sure yarn --immutable is invoked correctly.

Testing the initial installation flow w/ npm i -g @electron/build-tools is more tricky, since that package automatically pulls the main branch. If anyone has ideas about how to test this, I'd be happy to do that additional testing.

@itsananderson itsananderson requested review from a team and ckerr as code owners October 6, 2025 18:32
@socket-security
Copy link

socket-security bot commented Oct 6, 2025

Comment on lines 125 to 126
console.log(color.childExec('npx', ['yarn', '--immutable'], execOpts));
cp.execSync('npx yarn --immutable', execOpts);
Copy link
Member

Choose a reason for hiding this comment

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

npx is unsafe and now we have the yarn cjs file we can just do node .yarn/releases/yarn-4.10.3.cjs instead.

I'm also fairly sure this will fail on the first run through because yarn --prod will run from the old script while having the new code locally

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, ya I was wondering about this.. node .yarn/releases/yarn-4.10.3.cjs sounds like a good alternative.

Let me think about the yarn --prod issue.. maybe I need to send a separate PR to prepare for this migration, and then wait a little bit before merging this PR 🤔

Copy link
Member

Choose a reason for hiding this comment

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

You could do something truly nasty and bit a yarn binary in this folder so that npx runs it instead of global yarn 😨 But hey that's the voice inside my head talking

Copy link
Member Author

Choose a reason for hiding this comment

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

Does npx pick up arbitrary binaries out of a local repo? I wasn't aware of that behavior.

We could maybe write a shim file to node_modules/.bin/yarn which npx would pick up.. and I guess we could have that wrapper detect and handle the --prod flag to give a graceful transition... but it'd definitely be a bit hacky.

Copy link
Member Author

Choose a reason for hiding this comment

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

In the interest of moving this forward, here are some other options:

  1. Land the change as-is, and post one-time instructions for people to run after build-tools updates and fails to run yarn --prod
  2. Update build-tools to look for a gitignored sentinal file for all e commands, and if it's not present, run yarn install --immutable before running the actual command, then touch the sentinal file. This way even if people get an error when yarn --prod runs, build-tools would "self-heal" when the next e command is run

I don't have a strong opinion about how to solve this, though since there's a limited user base, it seems like a simpler solution + some manual upgrade instructions might be the right balance of effort.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should be OK to just Let This Happen.

We can post in #pineapple internally that this will happen, it will auto-fix on the next update. People won't be broken, they'll get an error once and then it will fix on the next e command they run

@notion-workspace
Copy link

build-tools

@codebytere
Copy link
Member

@itsananderson could you rebase?

@socket-security
Copy link

socket-security bot commented Nov 5, 2025

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
High CVE: npm minimatch ReDoS vulnerability

CVE: GHSA-f8q6-p94x-37v3 minimatch ReDoS vulnerability (HIGH)

Affected versions: < 3.0.5

Patched version: 3.0.5

From: ?npm/[email protected]npm/[email protected]

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at [email protected].

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/[email protected]. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: npm semver vulnerable to Regular Expression Denial of Service

CVE: GHSA-c2qf-rxjj-qqgw semver vulnerable to Regular Expression Denial of Service (HIGH)

Affected versions: >= 7.0.0 < 7.5.2; >= 6.0.0 < 6.3.1; < 5.7.2

Patched version: 6.3.1

From: ?npm/[email protected]npm/[email protected]

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at [email protected].

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/[email protected]. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Medium
Deprecated by its maintainer: npm debug

Reason: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/debug-js/debug/issues/797)

From: ?npm/[email protected]npm/[email protected]

ℹ Read more on: This package | This alert | What is a deprecated package?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at [email protected].

Suggestion: Research the state of the package and determine if there are non-deprecated versions that can be used, or if it should be replaced with a new, supported solution.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/[email protected]. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@itsananderson
Copy link
Member Author

I've rebased. I'm struggling to reproduce the test timeout errors that are happening in CI, though 🤔

@itsananderson
Copy link
Member Author

Also, do we care about the ReDoS warnings for this repo? It seems unlikely that those could be exploited in build-tools, but I'm happy to try to address those if needed.

@itsananderson
Copy link
Member Author

Ah, so regenerating the yarn.lock file bumped vitest from 3.0.6 to 3.2.4, and according to this vitest discussion this was a regression introduced somewhere between 3.0.9 and 3.1.3, which the maintainers aren't interested in backporting to vitest 3.

From those details, it sounds like the best options are probably to either:

  1. Upgrade to vitest 4 to get the fix
  2. Pin vitest to 3.0.6 so that this Yarn upgrade doesn't introduce the regression

@itsananderson
Copy link
Member Author

Ok, pinning to only accept patch versions of vitest@~3.0.6 fixed the CI errors. That seems preferable since presumably a vitest@4 upgrade would require more significant changes.

@dsanders11
Copy link
Member

That seems preferable since presumably a vitest@4 upgrade would require more significant changes.

I'm good with pinning it, but I've test migrated a couple of repos to Vitest v4 and so far it's been a pretty painless migration.

@codebytere codebytere merged commit 7da221c into electron:main Nov 9, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants