diff --git a/internal/devpkg/package.go b/internal/devpkg/package.go index c0b2d9ce539..956a1372038 100644 --- a/internal/devpkg/package.go +++ b/internal/devpkg/package.go @@ -416,13 +416,7 @@ func (p *Package) Versioned() string { } func (p *Package) IsLegacy() bool { - if !p.IsDevboxPackage() || p.isVersioned() { - return false - } - if p.IsInstallable() { - return false - } - return p.lockfile.Get(p.Raw).GetSource() == "" + return p.IsDevboxPackage() && !p.isVersioned() && p.lockfile.Get(p.Raw).GetSource() == "" } func (p *Package) LegacyToVersioned() string { @@ -554,3 +548,12 @@ func (p *Package) StoreName() (string, error) { } return name, nil } + +func (p *Package) EnsureUninstallableIsInLockfile() error { + // TODO savil: Do we need the IsDevboxPackage check here? + if !p.IsInstallable() || !p.IsDevboxPackage() { + return nil + } + _, err := p.lockfile.Resolve(p.Raw) + return err +} diff --git a/internal/impl/packages.go b/internal/impl/packages.go index b6ab41f7537..3c477ce8b45 100644 --- a/internal/impl/packages.go +++ b/internal/impl/packages.go @@ -235,6 +235,17 @@ func (d *Devbox) ensurePackagesAreInstalled(ctx context.Context, mode installMod return err } + // Update lockfile with new packages that are not to be installed + cfgPkgs, err := d.ConfigPackages() + if err != nil { + return err + } + for _, pkg := range cfgPkgs { + if err := pkg.EnsureUninstallableIsInLockfile(); err != nil { + return err + } + } + return d.lockfile.Save() }