jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
7.84k stars 188 forks source link

Revert "[perf] Skip cache check if store path exists locally" #2054

Closed mikeland73 closed 1 month ago

mikeland73 commented 1 month ago

Reverts jetify-com/devbox#2042

jetify-com/devbox#2042 introduced a bug where adding non-cached packages would fail to add them to the flake on the first attempt. (it would succeed on subsequent attempts after the package is already in the store).

The root cause is that fetchNarInfoStatus gets called twice per package (even though we cache it and we're not supposed to call it twice). The first call returns false because the package is not cached. The second call returns true because the package is already in store. This discrepancy essentially causes the package not to appear on the flake at all. When updating state again, the package is already in the nix store so both fetchNarInfoStatus calls return true.

I think reverting this is best immediate course of action. In follow up we should fix fetchNarInfoStatus so it only gets called once (it will improve performance and is more correct).

Later on we can think of better way to do jetify-com/devbox#2042. The current implementation is a bit fragile and not 100% consistent with the initial intention of the function, so I'm concerned it can lead to more bugs in the future.