Skip to content

Commit 14ab456

Browse files
authored
[remove nixpkgs] bug fix: update only the user's sysInfo, rather than for all systems (#1259)
## Summary @mikeland73 points out that this line was erroneously updating all SystemInfos: https://github.com/jetpack-io/devbox/pull/1256/files#r1256408509 Instead, we should only update the missing SystemInfo of the user's current system. ## How was it tested? - [x] do `devbox update` of a lockfile having another system's SystemInfo
1 parent b100a0b commit 14ab456

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

internal/devpkg/package.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@ func (p *Package) ContentAddressedPath() (string, error) {
533533

534534
ux.Fwarning(
535535
os.Stderr,
536-
"calculating local_store_path. This may be slow.\n"+
537-
"Run `devbox update` to speed this up for next time.",
536+
"calculating ca_store_path. This may be slow. "+
537+
"Run `devbox update` to speed this up for next time.\n",
538538
)
539539
localPath, err := nix.ContentAddressedStorePath(sysInfo.StorePath)
540540
if err != nil {

internal/impl/update.go

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"go.jetpack.io/devbox/internal/boxcli/featureflag"
1111
"go.jetpack.io/devbox/internal/devpkg"
12+
"go.jetpack.io/devbox/internal/lock"
1213
"go.jetpack.io/devbox/internal/nix"
1314
"go.jetpack.io/devbox/internal/nix/nixprofile"
1415
"go.jetpack.io/devbox/internal/searcher"
@@ -115,22 +116,30 @@ func (d *Devbox) updateDevboxPackage(
115116
return err
116117
}
117118

118-
// Check if the system info is missing for the user's system.
119-
sysInfo := d.lockfile.Packages[pkg.Raw].Systems[userSystem]
120-
if sysInfo == nil {
121-
d.lockfile.Packages[pkg.Raw] = newEntry
122-
ux.Finfo(d.writer, "Updated system information for %s\n", pkg)
123-
return nil
124-
}
119+
// If the newEntry has a system info for the user's system,
120+
// then check if we need to update system info
121+
if newEntry.Systems[userSystem] != nil {
122+
123+
// Check if the system info is missing for the user's system.
124+
sysInfo := d.lockfile.Packages[pkg.Raw].Systems[userSystem]
125+
if sysInfo == nil {
126+
if d.lockfile.Packages[pkg.Raw].Systems == nil {
127+
d.lockfile.Packages[pkg.Raw].Systems = map[string]*lock.SystemInfo{}
128+
}
129+
d.lockfile.Packages[pkg.Raw].Systems[userSystem] = newEntry.Systems[userSystem]
130+
ux.Finfo(d.writer, "Updated system information for %s\n", pkg)
131+
return nil
132+
}
125133

126-
// Check if the CAStorePath is missing for the user's system.
127-
// Since any one user cannot add this field for all systems,
128-
// we'll need to progressively add it to a project's lockfile.
129-
if sysInfo.CAStorePath == "" {
130-
// Update the CAStorePath for the user's system
131-
d.lockfile.Packages[pkg.Raw].Systems[userSystem].CAStorePath = newEntry.Systems[userSystem].CAStorePath
132-
ux.Finfo(d.writer, "Updated system information for %s\n", pkg)
133-
return nil
134+
// Check if the CAStorePath is missing for the user's system.
135+
// Since any one user cannot add this field for all systems,
136+
// we'll need to progressively add it to a project's lockfile.
137+
if sysInfo.CAStorePath == "" {
138+
// Update the CAStorePath for the user's system
139+
d.lockfile.Packages[pkg.Raw].Systems[userSystem].CAStorePath = newEntry.Systems[userSystem].CAStorePath
140+
ux.Finfo(d.writer, "Updated system information for %s\n", pkg)
141+
return nil
142+
}
134143
}
135144
}
136145

0 commit comments

Comments
 (0)