File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -957,6 +957,13 @@ func (d *Devbox) ensurePackagesAreInstalledAndComputeEnv(
957
957
) (map [string ]string , error ) {
958
958
defer debug .FunctionTimer ().End ()
959
959
960
+ // We need to check the lockfile status prior to ensurePackagesAreInstalled
961
+ // since it will update the lockfile to be up-to-date.
962
+ upToDate , err := d .lockfile .IsUpToDateAndInstalled ()
963
+ if err != nil {
964
+ return nil , err
965
+ }
966
+
960
967
// When ensurePackagesAreInstalled is called with ensure=true, it always
961
968
// returns early if the lockfile is up to date. So we don't need to check here
962
969
if err := d .ensurePackagesAreInstalled (ctx , ensure ); err != nil && ! strings .Contains (err .Error (), "no such host" ) {
@@ -965,11 +972,7 @@ func (d *Devbox) ensurePackagesAreInstalledAndComputeEnv(
965
972
ux .Fwarning (d .stderr , "Error connecting to the internet. Will attempt to use cached environment.\n " )
966
973
}
967
974
968
- // Since ensurePackagesAreInstalled calls computeNixEnv when not up do date,
969
- // it's ok to use usePrintDevEnvCache=true here always. This does end up
970
- // doing some non-nix work twice if lockfile is not up to date.
971
- // TODO: Improve this to avoid extra work.
972
- return d .computeNixEnv (ctx , true )
975
+ return d .computeNixEnv (ctx , upToDate /*usePrintDevEnvCache*/ )
973
976
}
974
977
975
978
func (d * Devbox ) nixPrintDevEnvCachePath () string {
You can’t perform that action at this time.
0 commit comments