Skip to content

feat(env)!: replace Corepack with package manager shims - #2391

Open
liangmiQwQ wants to merge 3 commits into
voidzero-dev:mainfrom
liangmiQwQ:feat-breaking/remove-corepack-always-expose-pm-shims
Open

feat(env)!: replace Corepack with package manager shims#2391
liangmiQwQ wants to merge 3 commits into
voidzero-dev:mainfrom
liangmiQwQ:feat-breaking/remove-corepack-always-expose-pm-shims

Conversation

@liangmiQwQ

@liangmiQwQ liangmiQwQ commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

The first part of #2375.
Related to #858, #1309.

Breaking Change: users can no longer access corepack binary, nor can they run vp install -g pnpm (also corepack, bun, yarn) as they did before. The missing feature, like corepack use and install specific-pnpm version as failback, will be shipped in the second PR (vp env enhancement)

This PR removes the Corepack integration from the global CLI and environment setup flow. vp env setup now owns shims for npm/npx, pnpm/pnpx, Yarn/yarnpkg, and Bun/bunx, resolving project-declared versions while keeping npm bundled with Node.js.

Refreshing the environment removes legacy managed package-manager installs and stale Corepack shims so old state cannot shadow the new defaults. Installer scripts, docs, and CLI snapshots are updated to match.

Two follow-up layers are staged in the fork and will be submitted sequentially after prior layers merge.

Bun and pnpm 12 native-binary support already exists on main (#2151, #2289). This PR reuses it and adds coverage for reaching it through the new default shims.

🤖 Generated with Codex

@netlify

netlify Bot commented Aug 9, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit e127601
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a79c6f57d600e0009072463

@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 86e420d5a6

ℹ️ 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".

Comment thread crates/vp_global_cli/src/shim/dispatch.rs
Comment thread crates/vp_global_cli/src/commands/env/setup.rs
Comment thread packages/cli/install.ps1 Outdated
Comment thread crates/vp_global_cli/src/commands/env/setup.rs
Comment thread crates/vp_global_cli/src/shim/dispatch.rs
@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 706d8e318c

ℹ️ 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".

Comment thread crates/vp_global_cli/src/commands/env/setup.rs
Comment thread crates/vp_global_cli/src/shim/dispatch.rs Outdated
@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0c08fd4bbd

ℹ️ 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".

Comment thread crates/vp_global_cli/src/commands/env/which.rs
Comment thread crates/vp_global_cli/src/commands/env/which.rs Outdated
@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0b07212bb3

ℹ️ 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".

Comment thread crates/vp_global_cli/src/commands/env/setup.rs
Comment thread crates/vp_global_cli/src/shim/dispatch.rs Outdated
@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a7e22c2808

ℹ️ 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".

Comment thread packages/cli/install.sh Outdated
Comment thread crates/vp_global_cli/src/shim/dispatch.rs Outdated
Comment thread crates/vp_global_cli/src/commands/env/setup.rs
@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cbb9b57ba3

ℹ️ 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".

Comment thread crates/vp_setup/src/install.rs Outdated
@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

// For bun, use platform-specific download flow.
// The hash from `packageManager` field belongs to the main `bun` npm package,
// not the platform-specific binary, so we don't pass it through; the
// platform tarball is verified against the registry's `dist.integrity`.
if matches!(package_manager_type, PackageManagerType::Bun) {
return download_bun_package_manager(&version, &home_dir).await;

P1 Badge Verify Bun's declared package-manager hash

When a project uses an integrity-pinned declaration such as packageManager: "bun@1.2.3+sha512...", this branch discards expected_hash, so even an incorrect pin succeeds and the downloaded native binary runs. Verifying the platform tarball against dist.integrity fetched from the same registry does not enforce the user-declared hash; verify the Bun package artifact named by the declaration, as the native pnpm path does.

ℹ️ 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".

Comment thread crates/vp_setup/src/install.rs Outdated
@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e45fa4a9bd

ℹ️ 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".

Comment thread crates/vp_setup/src/install.rs Outdated
@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd92acbfd0

ℹ️ 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".

Comment thread crates/vp_global_cli/src/commands/global/install.rs
Comment thread crates/vp_global_cli/src/shim/dispatch.rs Outdated
Comment thread crates/vp_setup/src/install.rs Outdated
@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92424fbef1

ℹ️ 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".

Comment thread crates/vp_setup/src/install.rs Outdated
@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

Cleaned up the review-driven follow-ups in d0cc793: removed alias repair, env which expansion, mismatched-manager fallback, npm ownership tracking, downgrade cleanup, and transactional shim backup/restore. Those behaviors are either deferred product work, unsupported damaged-state recovery, or conflict with this PRs breaking-change boundary. Retained only direct normal-path fixes: cached unpinned managers, native Bun/pnpm runtime handling, Node override/error propagation, complete installer disclosure, and an explicit error for vp install -g corepack. The cleanup commit is +91/-855; the full PR is now +452/-1321.

@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex review

@liangmiQwQ

liangmiQwQ commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator Author

Final follow-up pushed:

  • 301e3415 removes the Bun/pnpm 12 no-Node special case. All package-manager shims consistently resolve and prepend the managed Node runtime.
  • d004370f reverts the unrelated Bun hash change; that issue predates this PR.
  • 7c464f25 follows Corepack’s known-good release policy for unpinned managers: initialize once from latest, reuse offline, and only advance within the same major.

No further Codex review requested.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: d0cc7937d2

ℹ️ 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
liangmiQwQ marked this pull request as ready for review August 10, 2026 06:59
@fengmk2 fengmk2 self-assigned this Aug 10, 2026
@fengmk2 fengmk2 added the preview-build Publish this PR's commits to the registry bridge as preview builds label Aug 10, 2026
'vpr',
];

for (const shim of ['vp', 'node', 'npm', 'npx', 'corepack', 'vpx', 'vpr']) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The reason we previously chose corepack was because we were unsure what side effects would result from defaulting to create shims for pnpm, yarn, and bun.
This is because it would prevent users from installing pnpm or bun themselves once they have installed vp.

We may need to make some modifications in install.sh to prompt users whether they want vp to manage pnpm, yarn, bun, etc., rather than defaulting to overriding their installations.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We may need to make some modifications in install.sh to prompt users whether they want vp to manage pnpm, yarn, bun, etc., rather than defaulting to overriding their installations.

I thought about that, so now vp env off can control the pnpm binary status like Node.js.

I also plan to introduce partial control like vp env off pm vp env on node in the second PR.

@liangmiQwQ liangmiQwQ Aug 10, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The reason we previously chose corepack was because we were unsure what side effects would result from defaulting to create shims for pnpm, yarn, and bun. This is because it would prevent users from installing pnpm or bun themselves once they have installed vp.

The first point, yes, but in order to divide the responsibilities, and reduce mixed up logic, the architecture requires Vite+ offers full control underlying package manager.

And since vp env will manage package managers soon, there are no problems if they want to install their own package managers.

@fengmk2

fengmk2 commented Aug 10, 2026

Copy link
Copy Markdown
Member

@liangmiQwQ You can continue to complete and submit the remaining 2 PRs, and I will continue the review. Once all 3 PRs have no special issues, I will merge them in one go.

@liangmiQwQ

liangmiQwQ commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator Author

@liangmiQwQ You can continue to complete and submit the remaining 2 PRs, and I will continue the review. Once all 3 PRs have no special issues, I will merge them in one go.

@fengmk2 Should I just submit them towards main? I'm worried that will make the second PR includes the first PR's diff, as well as the third one.

@liangmiQwQ
liangmiQwQ force-pushed the feat-breaking/remove-corepack-always-expose-pm-shims branch from c7e51be to c3c58d0 Compare August 10, 2026 07:54
fengmk2 added a commit that referenced this pull request Aug 10, 2026
Two fixes to `main`, both found by the first real runs of the publishing
workflow. It could not be exercised before merge, because `workflow_run`
only fires for workflow files already on the default branch.

**First, the good news: the design works.** PR #2328 published end to
end through the new path with an OIDC token, no admin token involved.
`authorize`, `Pkg Preview`, and the sticky comment all succeeded, and
`commit.a7180fa85c06fad48` is on the bridge:

```
commit.a7180fa85c06fad48 | pr: .../pull/2328 | at: 2026-08-10T07:35:31.617Z
```

## 1. Fork PRs could not be resolved at all

#2391 (from `liangmiQwQ`) failed in `authorize` with `no open PR of
voidzero-dev/vite-plus has head c7e51be…` while that PR was open with
exactly that head.

`listPullRequestsAssociatedWithCommit` returns **empty** for a fork PR's
head commit. Confirmed against the live API:

| commit | result |
| --- | --- |
| #2387 head (same-repo) | returns `#2387` |
| #2391 head (fork) | **empty** |

So it worked for every case reachable before merge and failed for the
only case this feature exists for. `workflow_run.pull_requests` is empty
for forks too, which is what sent me to the commit endpoint originally —
I swapped one fork-blind source for another.

Now resolves via `pulls?state=open&head=<head_owner>:<head_branch>`,
both GitHub-signed payload fields. The head-sha match is a separate step
so the message distinguishes "no such PR" from "the PR moved on":

```
fork PR 2391 (real failure) -> OK: #2391 labeled=true fork=true
stale head                  -> FAIL: PR #2391 now at c7e51be, built 0000000
no such branch              -> FAIL: no open PR from liangmiQwQ:does-not-exist
```

I re-checked the rest of the publishing workflow for the same blind
spot. Everything else keys off the PR number or the run id, which are
base-repo objects and fork-safe: the post-approval `pulls.get` re-check
returns correct state, head and labels for #2391, and the artifact
download and the `listWorkflowRunArtifacts` precondition both see that
run's 148MB `bridge-packages`.

## 2. The Docker gha cache broke the image push

```
#14 exporting to GitHub Actions Cache
#14 ERROR: error writing layer blob: failed to reserve cache
#13 exporting to image ... CANCELED
```

The cache export is fatal to the build, so it cancelled the push. I
added this in the cleanup pass; it broke the job it was meant to speed
up, and #2328's npm preview published while its Docker image did not.

Reverted rather than repaired. Making it work needs `actions: write` on
the one job that installs and executes the preview package, which is the
job SR-5 says to keep unprivileged, and this was the only `type=gha`
usage in the repo so there was no working precedent. It was saving
60-90s of apt on a path that already waits on a human approval measured
in minutes to days.

## 3. Terminology

"Trusted leg" and "build leg" were my own coinage and meant nothing to a
reader who was not in the design conversation. The two workflows are now
described as **the build workflow** and **the publishing workflow**, and
where trust was the point the property is stated rather than encoded in
a name.

This also surfaced something worth fixing later: `publish-preview.yml`
is named "Publish preview build" and no longer publishes anything.
Renaming it is the real fix, but the publishing workflow matches it by
`name:`, so that has to be a coordinated change. The header says so
outright for now.

The same terminology fix for the RFC and bridge docs is
voidzero-dev/pkg-pr-registry-bridge#93, which also corrects SR-1 for the
fork-blind endpoint above.

## After merging

Re-label #2391 to get the first genuine fork preview.
@fengmk2

fengmk2 commented Aug 10, 2026

Copy link
Copy Markdown
Member

@liangmiQwQ You can have the agent handle it, which should be able to do this kind of thing well. Even without stacked PRs, it can create PRs by branch.

@liangmiQwQ
liangmiQwQ force-pushed the feat-breaking/remove-corepack-always-expose-pm-shims branch from c3c58d0 to 5c2cae7 Compare August 10, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview-build Publish this PR's commits to the registry bridge as preview builds

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants