Skip to content

Commit ad6e464

Browse files
mikeland73claude
andcommitted
Fix devbox update <pkg> installing all packages instead of just the 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>
1 parent ea03d2d commit ad6e464

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

internal/devbox/devbox.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ type Devbox struct {
6868

6969
// This is needed because of the --quiet flag.
7070
stderr io.Writer
71+
72+
// packagesBeingUpdated tracks which packages are being updated so that
73+
// installNixPackagesToStore only refreshes those, not all packages.
74+
packagesBeingUpdated []*devpkg.Package
7175
}
7276

7377
var legacyPackagesWarningHasBeenShown = false

internal/devbox/packages.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ func (d *Devbox) packagesToInstallInStore(ctx context.Context, mode installMode)
637637
packagesToInstall := []*devpkg.Package{}
638638
storePathsForPackage := map[*devpkg.Package][]string{}
639639
for _, pkg := range packages {
640-
if mode == update {
640+
if mode == update && d.isBeingUpdated(pkg) {
641641
packagesToInstall = append(packagesToInstall, pkg)
642642
continue
643643
}
@@ -666,6 +666,15 @@ func (d *Devbox) packagesToInstallInStore(ctx context.Context, mode installMode)
666666
return lo.Uniq(packagesToInstall), nil
667667
}
668668

669+
func (d *Devbox) isBeingUpdated(pkg *devpkg.Package) bool {
670+
for _, u := range d.packagesBeingUpdated {
671+
if u.Raw == pkg.Raw {
672+
return true
673+
}
674+
}
675+
return false
676+
}
677+
669678
// moveAllowInsecureFromLockfile will modernize a Devbox project by moving the allow_insecure: boolean
670679
// setting from the devbox.lock file to the corresponding package in devbox.json.
671680
//

internal/devbox/update.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ func (d *Devbox) Update(ctx context.Context, opts devopt.UpdateOpts) error {
8080
}
8181
}
8282

83+
d.packagesBeingUpdated = inputs
84+
8385
mode := update
8486
if opts.NoInstall {
8587
mode = noInstall

0 commit comments

Comments
 (0)