Skip to content

fix(global): introduce install id for global installation#1906

Open
liangmiQwQ wants to merge 11 commits into
voidzero-dev:mainfrom
liangmiQwQ:liang/codex/global-install-id
Open

fix(global): introduce install id for global installation#1906
liangmiQwQ wants to merge 11 commits into
voidzero-dev:mainfrom
liangmiQwQ:liang/codex/global-install-id

Conversation

@liangmiQwQ

@liangmiQwQ liangmiQwQ commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

The global package reinstall flow introduced by #1698 installs into the final prefix, but it first moves the active prefix to a backup. An interruption can leave the installed package unavailable, and the approaches explored in #1770 and #1773 trade that failure mode for other windows where bins can still break.

This PR adds an install ID to managed package metadata. Each install now writes directly to a sibling prefix such as packages/<name>#<uuid>, then activates that immutable directory by saving metadata after npm succeeds. The ID is a standard UUID v4 prefixed with #, which is filesystem-safe but invalid in npm package names. Binary dispatch, vp env which, vpx, and global outdated output resolve the active directory from metadata, so no installed prefix is moved.

Metadata without installId, or with an empty value, continues to resolve packages/<name> for compatibility with existing installations. A successful reinstall deletes only the installation it directly replaced. Cleanup of any older interrupted-install directories through vp upgrade is intentionally left to a follow-up PR.

🤖 Generated with Codex

@netlify

netlify Bot commented Jun 21, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

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

@liangmiQwQ liangmiQwQ changed the title fix(global): activate immutable package installs fix(global): introduce install id for global installation Jun 22, 2026
Comment thread .github/workflows/ci.yml
@liangmiQwQ liangmiQwQ marked this pull request as ready for review June 22, 2026 01:10
@fengmk2

fengmk2 commented Jun 22, 2026

Copy link
Copy Markdown
Member

@codex review

@fengmk2 fengmk2 added test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: create-e2e Run `vp create` e2e tests labels Jun 22, 2026

@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: fc9645b7c8

ℹ️ 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/vite_global_cli/src/commands/global/install.rs
Comment thread crates/vite_global_cli/src/commands/global/install.rs
Comment thread crates/vite_global_cli/src/commands/global/install.rs Outdated
Comment on lines +613 to +614
match PackageMetadata::load(package_name).await {
Ok(Some(metadata)) if metadata.install_id == current_install_id => {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Re-check active metadata before deleting siblings

When two vp install -g <same package> processes overlap, this check can pass for install A, then install B can save metadata for its own install ID before A reaches the deletion loop. A will still delete every sibling except its own directory, including B's now-active directory, leaving metadata and shims pointing at a removed package tree.

Useful? React with 👍 / 👎.

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.

I've thought about only deleing the current using package before, but I am worried about interruption will bring stale packages in this way. Maybe a good balance is to only deleting the current using package there, and handling other rubbish files while upgrading.

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.

I modified the implementation to only delete original package, and the cleaning work may need doing on another PR.

@liangmiQwQ liangmiQwQ marked this pull request as draft June 22, 2026 08:26

@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: 1311ca417f

ℹ️ 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/snap-tests-global/env-install-interrupt/test-reinstall-interrupt.js Outdated
@liangmiQwQ liangmiQwQ marked this pull request as ready for review June 22, 2026 09:48
@liangmiQwQ liangmiQwQ requested a review from fengmk2 June 22, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests test: install-e2e run vite install e2e test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants