Skip to content

Conversation

@ibilalkayy
Copy link
Contributor

@ibilalkayy ibilalkayy commented Oct 22, 2025

What does this PR try to resolve?

This PR is trying to improve the error message when the wrong package is found in the path dependency. Currently the PR started from the tests.

How to test and review this PR?

There are 3 tests added that cover each case that is brought up in this issue.

  • invalid_package_name_in_path()

    • It reads the main manifest file to find that the definitely_not_bar exists in the crates/bar and it goes to the crates/bar to find that it is not present there and it gives the error.
  • invalid_package_in_subdirectory()

    • It reads the main manifest file to find that the definitely_not_bar exists in the crates/bar and after going there, it does not find it. Then it goes more deeper in the definitely_not_bar to find that the manifest file exists there and give use the helpful message.
  • invalid_manifest_in_path()

    • It reads the main manifest file to find that definitely_not_bar exists in the crates/bar but after going there, it finds that there are other two packages but definitely_not_bar is not present and it gives the message.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 22, 2025

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@epage epage marked this pull request as draft October 22, 2025 14:20
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 22, 2025
.file("crates/bar/src/lib.rs", "")
.build();

p.cargo("check")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
p.cargo("check")
p.cargo("generate-lockfile")

Since these tests don't need building, this should make them run faster

Comment on lines +1957 to +1961
error: no matching package named `definitely_not_bar` found at `bar/`
note: required by package `foo v0.1.0 (/Users/eric/Temp/foo)`
help: package `bar` exists at `bar/`
"#]])
Copy link
Contributor

Choose a reason for hiding this comment

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

As a Draft, I appreciate showing your intent in shopping this around.

As you work on this, I'd recommend making the tests pass, showing the current behavior. Your next commit would then change Cargo's behavior and update the tests to show the new test output.

)
.run();
}
// #[cargo_test]
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be commented out

@epage epage changed the title wrote 3 tests about improving the error message in the path dependency WIP: wrote 3 tests about improving the error message in the path dependency Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants