Skip to content

Fix update installing all packages instead of target#2816

Merged
mikeland73 merged 3 commits intomainfrom
mikeland73/fix-flake-resolve-loop
Apr 15, 2026
Merged

Fix update installing all packages instead of target#2816
mikeland73 merged 3 commits intomainfrom
mikeland73/fix-flake-resolve-loop

Conversation

@mikeland73
Copy link
Copy Markdown
Collaborator

@mikeland73 mikeland73 commented Apr 15, 2026

Summary

  • Fixes devbox update <pkg> causing all packages to be re-installed instead of just the specified one
  • Tracks which packages are being updated via a new field on the Devbox struct
  • packagesToInstallInStore() now only force-installs the targeted packages; others go through the normal store-path check

Fixes #2653

Test plan

  • Run devbox update <single-pkg> with multiple packages in devbox.json — only the target should be installed
  • Run devbox update (no args) — all packages should still be updated

… target

When running `devbox update <pkg>`, packagesToInstallInStore() was
unconditionally adding every package to the install list in update mode.
This caused all packages to be re-installed with --refresh, not just the
ones the user requested.

Track which packages are being updated via a field on the Devbox struct
and only force-install those in packagesToInstallInStore(). Other packages
still go through the normal store-path check.

Fixes #2653

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mikeland73 mikeland73 requested review from gcurtis and savil April 15, 2026 18:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes devbox update <pkg> unintentionally (re)installing all configured packages by tracking the update targets on Devbox and only force-refreshing those packages during the store-install step.

Changes:

  • Add packagesBeingUpdated to Devbox and set it during Update.
  • Change store-install selection so update mode force-installs only the targeted packages; other packages still follow the normal “missing store path” check.
  • Add helper isBeingUpdated to check whether a package is part of the current update target set.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
internal/devbox/update.go Records the update targets on the Devbox instance before running ensureStateIsUpToDate.
internal/devbox/packages.go Adjusts packagesToInstallInStore to only force-refresh targeted packages; adds isBeingUpdated.
internal/devbox/devbox.go Extends Devbox state with packagesBeingUpdated to support targeted refresh behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +669 to +675
func (d *Devbox) isBeingUpdated(pkg *devpkg.Package) bool {
for _, u := range d.packagesBeingUpdated {
if u.Raw == pkg.Raw {
return true
}
}
return false
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

isBeingUpdated does a linear scan over d.packagesBeingUpdated for every package in packagesToInstallInStore. When updating all packages this becomes O(n²) and adds avoidable overhead. Consider representing the update targets as a map[string]struct{}/set keyed by pkg.Raw (or building such a set once) so membership checks are O(1).

Copilot uses AI. Check for mistakes.
Comment thread internal/devbox/update.go
Comment on lines +83 to +84
d.packagesBeingUpdated = inputs

Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

This change fixes a user-visible regression in devbox update <pkg> behavior, but there isn't a test covering the new “only refresh targeted packages” logic. Please add a regression test that exercises Update with a single package in a multi-package config and asserts only that package is selected for store installation/refresh (e.g., by stubbing the store-install selection or asserting on the emitted install list).

Copilot uses AI. Check for mistakes.
mikeland73 and others added 2 commits April 15, 2026 12:24
Tests that isBeingUpdated correctly filters packages so that only the
targeted packages are force-refreshed during `devbox update <pkg>`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mikeland73 mikeland73 merged commit 858d3a3 into main Apr 15, 2026
24 checks passed
@mikeland73 mikeland73 deleted the mikeland73/fix-flake-resolve-loop branch April 15, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Running devbox update <pkg> causes additional packages to be installed

3 participants