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

Unclear error message when workspace dep cannot be inherited in patch #12031

Open
Rustin170506 opened this issue Apr 25, 2023 · 1 comment
Open
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. A-patch Area: [patch] table override A-workspace-inheritance Area: workspace inheritance RFC 2906 C-bug Category: bug S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@Rustin170506
Copy link
Member

Rustin170506 commented Apr 25, 2023

Problem

Unclear error message when workspace dep cannot be inherited in patch. See also #12001 (comment)

Steps

  1. Try cannot_inherit_in_patch unit test.
#[cargo_test]
fn cannot_inherit_in_patch() {
    Package::new("bar", "0.1.0").publish();

    let p = project()
        .file(
            "Cargo.toml",
            r#"
            [workspace]
            members = []

            [workspace.dependencies]
            bar = { path = "bar" }

            [package]
            name = "foo"
            version = "0.2.0"

            [patch.crates-io]
            bar.workspace = true

            [dependencies]
            bar = "0.1.0"

        "#,
        )
        .file("src/main.rs", "fn main() {}")
        .build();

    p.cargo("check")
        .with_status(101)
        .with_stderr(
            "\
[WARNING] [CWD]/Cargo.toml: unused manifest key: patch.crates-io.bar.workspace
[WARNING] [CWD]/Cargo.toml: dependency (bar) specified without providing a local path, Git repository, version, \
or workspace dependency to use. \
This will be considered an error in future versions
[UPDATING] `dummy-registry` index
[ERROR] failed to resolve patches for `https://github.com/rust-lang/crates.io-index`

Caused by:
  patch for `bar` in `https://github.com/rust-lang/crates.io-index` points to the same source, but patches must point to different sources
",
        )
        .run();
}
  1. See the warnings and errors.

Possible Solution(s)

Give a clear error message to say Cargo can not inherit a workspace dep in patch.

Notes

No response

Version

cargo version --verbose
cargo 1.69.0 (6e9a83356 2023-04-12)
release: 1.69.0
commit-hash: 6e9a83356b70586d4b77613a6b33f9ea067b9cdf
commit-date: 2023-04-12
host: aarch64-apple-darwin
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.86.0 (sys:0.4.59+curl-7.86.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 13.2.1 [64-bit]
@Rustin170506 Rustin170506 added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Apr 25, 2023
@Muscraft Muscraft added the A-workspace-inheritance Area: workspace inheritance RFC 2906 label Apr 25, 2023
@weihanglo
Copy link
Member

From #9885 (comment),

If we try again in the future, we will likely try to use the future-incompatible warning system which can report potential breaking in dependencies ahead of time.

Though we need to design the system in Cargo first. Or we can rely on -Zlints to have fine-grain control of Cargo's warnings.

@weihanglo weihanglo added S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. A-diagnostics Area: Error and warning messages generated by Cargo itself. A-patch Area: [patch] table override and removed S-triage Status: This issue is waiting on initial triage. labels Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. A-patch Area: [patch] table override A-workspace-inheritance Area: workspace inheritance RFC 2906 C-bug Category: bug S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

No branches or pull requests

3 participants