Skip to content

Commit 1eb5988

Browse files
committed
[print-dev-env] Skip cache if lockfile has changed
1 parent 8c49985 commit 1eb5988

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

internal/impl/devbox.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -951,17 +951,20 @@ func (d *Devbox) ensurePackagesAreInstalledAndComputeEnv(
951951
) (map[string]string, error) {
952952
defer debug.FunctionTimer().End()
953953

954+
// We need to check the lockfile status prior to ensurePackagesAreInstalled
955+
// since it will update the lockfile to be up-to-date.
956+
upToDate, err := d.lockfile.IsUpToDateAndInstalled()
957+
if err != nil {
958+
return nil, err
959+
}
960+
954961
// When ensurePackagesAreInstalled is called with ensure=true, it always
955962
// returns early if the lockfile is up to date. So we don't need to check here
956963
if err := d.ensurePackagesAreInstalled(ctx, ensure); err != nil {
957964
return nil, err
958965
}
959966

960-
// Since ensurePackagesAreInstalled calls computeNixEnv when not up do date,
961-
// it's ok to use usePrintDevEnvCache=true here always. This does end up
962-
// doing some non-nix work twice if lockfile is not up to date.
963-
// TODO: Improve this to avoid extra work.
964-
return d.computeNixEnv(ctx, true)
967+
return d.computeNixEnv(ctx, upToDate /*usePrintDevEnvCache*/)
965968
}
966969

967970
func (d *Devbox) nixPrintDevEnvCachePath() string {

0 commit comments

Comments
 (0)