Skip to content

[print-dev-env] Skip cache if lockfile has changed #1674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/impl/devbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ func (d *Devbox) ensurePackagesAreInstalledAndComputeEnv(
// it's ok to use usePrintDevEnvCache=true here always. This does end up
// doing some non-nix work twice if lockfile is not up to date.
// TODO: Improve this to avoid extra work.
return d.computeNixEnv(ctx, true)
return d.computeNixEnv(ctx, true /*usePrintDevEnvCache*/)
}

func (d *Devbox) nixPrintDevEnvCachePath() string {
Expand Down
7 changes: 7 additions & 0 deletions internal/impl/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,13 @@ func (d *Devbox) ensurePackagesAreInstalled(ctx context.Context, mode installMod
return err
}

// Use the printDevEnvCache if we are adding or removing or updating any package,
// AND we are not in the shellenv-enabled environment of the current devbox-project.
usePrintDevEnvCache := mode != ensure && !d.IsEnvEnabled()
if _, err := d.computeNixEnv(ctx, usePrintDevEnvCache); err != nil {
return err
}

// Ensure we clean out packages that are no longer needed.
d.lockfile.Tidy()

Expand Down