-
Notifications
You must be signed in to change notification settings - Fork 248
[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
Conversation
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, this is potentially a really bad bug, that was mostly masked by the fact that we add profile to path. In practice it means that straightforward use of devbox works, but anything that messes with the environment beyond just installing packages might not be picked up at all.
Unfortunately I think the best easiest solution is to reintroduce d.computeNixEnv
into ensurePackagesAreInstalled
functions. (See https://github.com/jetpack-io/devbox/pull/1584/files for the exact place where it was before it was removed).
The reason is that the local lock file uses the print-dev-env cache as input and it's saved at the end of ensurePackagesAreInstalled
. This PR would create a new print-dev-env
but then never write the new hash to the local lock, so the next time ensurePackagesAreInstalledAndComputeEnv
gets called it would needlessly compute the environment again. By putting it inside of ensurePackagesAreInstalled
(right before the d.lockfile.Save()
call) ensures we save the correct hash.
(This solution is not perfect but it's very small so it limits the risk).
Some ideas for future improvement:
- Local lock file should be renamed to status hash or project hash or something more descriptive.
- We may want to change the interface of
lockfile.Save
(or in the futureprojectHash.Regen()
to take the actual environment instead of reading it from the file. This would ensure we can't accidentally read a stale environment by calling it at the wrong time.
1eb5988
to
6746aba
Compare
Good call! I overlooked the issue with the lockfile saving a stale hash of the print-dev-env output. Made the fix.
Agree
I don't follow this. What do you mean by actual environment ? Are you thinking that |
by actual environment I mean the output of ComputeNixEnv. Basically instead of just assuming that what is in cache is the correct value, we take a fresh value instead. |
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Summary
We need to skip the PrintDevEnvCache in ComputeNixEnv if lockfile is stale.
ensurePackagesAreInstalledAndComputeEnv
had made an assumption thatensurePackagesAreInstalled
will have calledcomputeNixEnv
already to ensurethe PrintDevEnvCache was updated. However, after some recent refactoring, we
no longer call
computeNixEnv
withinensurePackagesAreInstalled
.So, we now need to check the lockfile status, and skip the PrintDevEnvCache
if lockfile is stale.
How was it tested?
Had
patch_glibc:true
forhello
package. Diddevbox shell
and thensaw that
which hello
points to the patch-glibc flake's hello.exited devbox shell, and edited devbox.json to
patch_glibc:false
re-started
devbox shell
andwhich hello
now shows the regular nixhello
.Previously, it would still show the patch-glibc hello since
PATH
would not havebeen updated to omit that.