Skip to content

Fix bug when comparing profile item added by store path #1422

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 14 commits into from
Aug 29, 2023

Conversation

ipince
Copy link
Contributor

@ipince ipince commented Aug 28, 2023

Summary

When an package is added by store path, we can no longer recover the original package from the profile item itself, because the only information we have is the nix store path. So, some comparisons where we were trying to find if a profile item matched a devbox package were broken.

Here we introduce a Item.Matches(Package) function to return true if the item was installed from the package. It attempts to hide the complexity of whether the item was installed by store path or not inside it, so callers don't have to worry about it. Modified the callsites to ToPackage() to use Matches instead, which simplified some logic.

Also added a len == 0 check to calls to nix profile remove, since I noticed we were sometimes calling it with no arguments. No failures here, but just wasted time.

How was it tested?

Manually tested by adding/removing packages and logging all the profile-related calls and item/package comparisons.

@ipince ipince requested a review from savil August 28, 2023 21:14
@ipince ipince force-pushed the rodrigo/store-paths branch from 33692fa to 478b1ab Compare August 28, 2023 21:19
@ipince ipince force-pushed the rodrigo/item-to-pkg-bug branch from 7cea54a to 46827ab Compare August 28, 2023 21:19
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.

nice!

@ipince ipince force-pushed the rodrigo/store-paths branch from 478b1ab to e53d6e1 Compare August 29, 2023 02:58
@ipince ipince force-pushed the rodrigo/item-to-pkg-bug branch from 51345c7 to a2ec7a2 Compare August 29, 2023 02:58
Base automatically changed from rodrigo/store-paths to main August 29, 2023 04:44
@ipince ipince merged commit 4259d40 into main Aug 29, 2023
@ipince ipince deleted the rodrigo/item-to-pkg-bug branch August 29, 2023 08:15
mikeland73 added a commit that referenced this pull request Sep 12, 2023
## Summary

ProfileListIndex was broken for raw flakes. This would break `devbox
update`

I could have left the `return -1, errors.Wrap(nix.ErrPackageNotFound,
args.Package.String())` inside the if statement, but it seems safer to
just to attempt the slow matching instead of returning an error and only
returning an error after all matching fails.

Blame PR: #1422

## How was it tested?

```bash
devbox add github:F1bonacc1/process-compose/v0.43.1
devbox update
```
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