Skip to content

[ensure] Don't recompute environment if up to date #1625

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
Nov 14, 2023
Merged

Conversation

mikeland73
Copy link
Contributor

@mikeland73 mikeland73 commented Nov 14, 2023

Summary

This bug was introduced in #1584 and has at least 2 effects:

  • Perf regression (because we recompute environment all the time)
  • Plugins that create flakes may break if they create additional files in the same directory. (Another PR will address this issue in more depth)

How was it tested?

devbox add mysql80
devbox services up -b
devbox services stop

Copy link
Collaborator

@savil savil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof, can't believe I overlooked this in the code review. My bad too!

}

fmt.Fprintln(d.stderr, "Ensuring packages are installed.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be:


 	if mode == ensure { 
 	   // if mode is ensure and we are up to date, then we can skip the rest
 	   if upToDate {
 		return nil
           }
 	   fmt.Fprintln(d.stderr, "Ensuring packages are installed.")
 	}

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep! will change

@mikeland73 mikeland73 merged commit cca5828 into main Nov 14, 2023
@mikeland73 mikeland73 deleted the landau/fix branch November 14, 2023 20:10
mikeland73 added a commit that referenced this pull request Nov 15, 2023
## Summary

**What this fixes:**
When plugins create flake in a directory shared with other files, `nix
search` can break. (We use `nix search` to determine output path). For
example in the mysql plugin the flake would live side-by-side with the
`run` directory which has a sock file. `nix search` would recurse in
that directory and try to search for nix expressions and break because
the file had an unexpected format.

**How it was surfaced:**
This issue was previously hidden because we don't call `nix search` if a
package has already been installed. The bug fixed in
#1625 was causing us to
needlessly call `nix search` on stuff that was already

**Solution:**
The partial solution in this PR is to always create the flake in its own
dir. This is a bit fragile, e.g. someone can forget if writing their own
plugin. Longer term, we need a better way to extract the output path
from a custom flake. (I think `nix flake show` could do it without
causing the issues surfaced by search)

## How was it tested?

CICD tests all plugins with exampels.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants