Repository navigation
fix(pm): gate Yarn commands on the version yarnPath selects - #3532
Conversation
The Yarn launcher from packageManager hands commands to the release in yarnPath, but command gates, Berry argument branches, and the tips setting used the launcher version. When the versions differed, Vite+ could skip a supported command and exit with code 0. When an rc file or YARN_YARN_PATH can make the launcher delegate, ask it for its version and cache the answer under a key built from the rc files, the target release, the Yarn path variables, and the launcher version. Projects without such a setting start no extra process.
Run real Yarn launchers that delegate through yarnPath, including the Classic launcher, ignorePath, YARN_IGNORE_PATH, a release replaced in place, and failed version queries.
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b0cebd16ef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A trailing comment on a yarnPath line became part of the release path, so the cache key recorded a missing file and kept an old version after the release was replaced in place. Read quoted values up to their closing quote and plain values up to a comment. Yarn Berry matches YARN_* variables without regard to case, so a lowercase yarn_ignore_path, yarn_yarn_path, or yarn_rc_filename could change the effective version without changing the key. Match these names without regard to case for both detection and the cache key.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7615c0c9c4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Yarn Berry lets a later spelling of a YARN_* variable override an earlier one, so two environments with the same values under different spellings can select different releases. Hash the original names in environment order instead of sorted canonical names.
Name the inputs the cache key covers instead of claiming it tracks every input that can change the effective version, and read quoted rc values with split_once.
The unlink check also passed for a manifest that was never linked. Assert that vp link added a portal: resolution before each unlink that must remove it.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac5af1eaf4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The line scanner kept growing YAML rules for comments and quotes. Read .yarnrc.yml with serde_norway, which the workspace already builds through vt_workspace, and keep a small reader for Classic .yarnrc, which is not YAML. When an rc file does not parse, ask Yarn so it reports the error.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 41a8259bbc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Yarn accepts some rc files that serde_norway rejects, such as files with duplicate keys. The cache key then missed the yarnPath release, so a release replaced in place kept the old cached version. Ask Yarn on every command in that case instead of reading or writing the cache.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f8cd842a29
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
liangmiQwQ
left a comment
There was a problem hiding this comment.
It looks good to me overall. However, I'm not sure if the cache mechanism brings too much complexity and edge cases. I also ran Codex reviews in my app locally and found several more edge cases.
For me, I'd lean toward calling yarn --version directly when we detect a possible override, since there are also similar pnpm --version, bun --version calls when they are on PATH. If we still found it costly in practice, we might better to introduce something like a shared helper for that --version check?
(Need @fengmk2's idea 🙇)
|
Thanks, that makes sense to me. I added the cache to avoid an extra |
|
I agree with removing the cache. Let’s call |
The cache key had to follow Yarn's rc parsing, substitutions, and release files, and each mismatch could return a stale version. Ask the launcher with yarn --version whenever a setting may make it delegate, and drop the cache and the YAML parser. Detection now only looks for yarnPath or yarn-path in the rc files and for YARN_YARN_PATH, so a form that Vite+ cannot parse still leads to a query.
These steps replaced a release in place to check cache invalidation, which no longer exists.
Move the managed Yarn check out of dispatch, update the manager version only when Yarn may delegate, and replace the NODE_OPTIONS comment with a test that fails when the version query keeps user preloads.
Drop the patch-commit step that repeats the ignorePath unlink check, read package.json through one helper, and reject unknown verify modes.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
typos flagged the `caf` prefix of the previous byte string. The test only needs a byte that is not valid UTF-8.
… fix/yarn-effective-version
Non-UTF-8 rc files are uncommon. Keep the substitution case on the same line.
Closes #3327
Vite+ used the launcher version from
packageManagerto decide which Yarn commands, options, and argument forms to use. The launcher hands each command to the release inyarnPathunlessignorePathorYARN_IGNORE_PATHturns that off, so the two versions can differ.For example, a project pins
yarn@2.4.2inpackageManager, and its.yarnrc.ymlpointsyarnPathto a Yarn 3.8.7 release. Yarn 3 supportsunlink, but Vite+ checked the Yarn 2 launcher, printed a warning, skipped the command, and exited with code 0. Theportal:resolution stayed inpackage.json.Approach
yarnPathoryarn-pathin the rc files of the current, parent, and home directories, and forYARN_YARN_PATHin any letter case. A false match only costs oneyarn --version, so Vite+ does not parse the files.yarn --versionthrough the launcher on every command, so Yarn applies its own rules foryarnPath,ignorePath, substitutions, andYARN_IGNORE_PATH. A delegating query took about 200ms in a local test. Caching can be revisited if that causes a noticeable slowdown.yarnPathin.yarnrc.ymlin the current, parent, or home directoryyarn-pathin.yarnrcYARN_YARN_PATHignorePath: trueYARN_IGNORE_PATH=1Yarn version resolution after this change
Each package-manager command in a Yarn project follows this path before Vite+ resolves it.
flowchart TD A["A package-manager command runs in a Yarn project"] --> B{"Which Yarn runs it?"} B -- "Yarn found on PATH" --> C["Vite+ uses the version that Yarn reported from the project.<br/>No extra process starts."] B -- "Yarn downloaded by Vite+" --> D{"Can any setting make the launcher delegate?"} D -- "No, as in most Yarn 4 and Classic projects" --> E["Vite+ uses the launcher version.<br/>No extra process starts."] D -- "Yes, as in most Yarn 2 and 3 projects" --> F["Vite+ runs yarn --version through the launcher."] F --> G{"Did the query succeed?"} G -- "No" --> H["Vite+ stops with Yarn's output."] G -- "Yes" --> I["Vite+ resolves the command with that version."]