Skip to content

fix(global): clean stale global package installs on upgrade#1943

Closed
liangmiQwQ wants to merge 3 commits into
voidzero-dev:mainfrom
liangmiQwQ:liang/codex/cleanup-stale-global-installs
Closed

fix(global): clean stale global package installs on upgrade#1943
liangmiQwQ wants to merge 3 commits into
voidzero-dev:mainfrom
liangmiQwQ:liang/codex/cleanup-stale-global-installs

Conversation

@liangmiQwQ

@liangmiQwQ liangmiQwQ commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

The current global package install flow can leave inactive packages/<name>#<uuid> directories behind when an install is interrupted before metadata activation. Older legacy installs can also leave inactive packages/<name> directories without an install ID.

This PR makes vp upgrade run a best-effort cleanup for stale global package install directories. It preserves every active install directory recorded in metadata, including legacy installs where installId is empty, removes inactive identified and legacy install directories once they are old enough, and leaves malformed #... names alone.

Recent inactive install directories are kept so a concurrent vp install -g that has created its package prefix but not saved metadata yet cannot be deleted by upgrade cleanup.

🤖 Generated with Codex.

@netlify

netlify Bot commented Jun 25, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

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

@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex

@liangmiQwQ liangmiQwQ changed the title fix(global): clean stale package installs on upgrade fix(global): clean stale package global installs on upgrade Jun 25, 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: 004a2a241a

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

let has_install_id = name
.rfind(INSTALL_ID_PREFIX)
.is_some_and(|index| index > 0 && is_install_id(&name[index..]));
if !has_install_id || active_install_dirs.contains(path) {

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 Guard against deleting in-progress installs

If vp upgrade runs while another vp install -g is between creating packages/<pkg>#<uuid> in install_one and saving its PackageMetadata, this check treats that live directory as inactive and the cleanup removes it. The install can then continue and write metadata/shims pointing at a package directory that no longer exists, so stale cleanup needs an age/lock/coordination check before deleting identified dirs.

Useful? React with 👍 / 👎.

@liangmiQwQ liangmiQwQ changed the title fix(global): clean stale package global installs on upgrade fix(global): clean stale global package installs on upgrade Jun 25, 2026
@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

I have a better solution, we can maintain a File::lock() while running global installation, and all packages will be removed except the new install one and the locked one.

@liangmiQwQ liangmiQwQ closed this Jun 25, 2026
@liangmiQwQ liangmiQwQ deleted the liang/codex/cleanup-stale-global-installs branch June 25, 2026 06:43
fengmk2 pushed a commit that referenced this pull request Jun 25, 2026
The current global install cleanup only removes the install directory
recorded by previous metadata. If a reinstall is interrupted, unrecorded
package directories can stay behind, and the legacy empty install-id
package directory can also survive.

This PR keeps a file lock for each in-progress global package install
directory, then replaces the previous-install cleanup with a
same-package stale directory sweep. The sweep skips locked directories
so concurrent global installs are protected, and removes both
`package#installId` stale directories and the empty install-id layout.

Related:
-
#1906 (comment)
-
#1943 (comment)

🤖 Generated with Codex.
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.

1 participant