Skip to content
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

Improve error messaging when a dependency is not found #1241

Merged
merged 10 commits into from
Feb 5, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Feb 3, 2024

Previously, whenever we encountered a missing package we would throw an error without information about why the package was requested. This meant that if a transitive dependency required a missing package, the user would have no idea why it was even selected. Here, we track NotFound and NoIndex errors as NoVersions incompatibilities with an attached reason. Improves our test coverage for --no-index without --find-links.

The snapshots show a nice improvement.

I think this will also enable backtracking to another version if some version of transitive dependency has a missing dependency. I'll write a scenario for that next.

Requires astral-sh/pubgrub#22

@zanieb zanieb requested a review from charliermarsh February 3, 2024 16:32
@zanieb zanieb added the error messages Messaging when something goes wrong label Feb 3, 2024
@zanieb zanieb force-pushed the zb/package-not-found branch 2 times, most recently from 2f90628 to 785c9e7 Compare February 3, 2024 16:55
@zanieb zanieb force-pushed the zb/package-not-found branch from 785c9e7 to 915bd38 Compare February 3, 2024 16:56
@zanieb
Copy link
Member Author

zanieb commented Feb 3, 2024

I expect this to require some refactoring and polish, but it's ready for review.

@zanieb zanieb marked this pull request as ready for review February 3, 2024 23:17
);
return Ok(Dependencies::Unavailable(
"The package is unavailable".to_string(),
));
Copy link
Member

Choose a reason for hiding this comment

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

This should never happen, right?

Copy link
Member

Choose a reason for hiding this comment

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

(Wondering if the whole thing should be a debug assert so that we don't have to do this extra hash lookup in release, but what you have here is probably better, it's negligible.)

Copy link
Member Author

@zanieb zanieb Feb 5, 2024

Choose a reason for hiding this comment

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

Yeah this should never happen. I am just hesitant to panic in production.

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

I think this looks great.

@zanieb zanieb merged commit d090acf into main Feb 5, 2024
6 checks passed
@zanieb zanieb deleted the zb/package-not-found branch February 5, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error messages Messaging when something goes wrong
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants