Skip to content

Cargo panics when using path dep and specifying a branch for it #11540

Closed
@kchibisov

Description

@kchibisov

Problem

While the message is pretty clean, it should not panic and throw an error.

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: key `branch` is ignored for dependency (sctk).', src/tools/cargo/src/cargo/util/toml/mod.rs:1852:14
stack backtrace:
   0: rust_begin_unwind
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:65:14
   2: core::result::unwrap_failed
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/result.rs:1791:5
   3: <cargo::util::toml::TomlManifest>::to_real_manifest
   4: cargo::util::toml::read_manifest_from_str
   5: cargo::util::toml::read_manifest
   6: <cargo::core::workspace::Packages>::load
   7: <cargo::core::workspace::Workspace>::find_root
   8: <cargo::core::workspace::Workspace>::new
   9: <clap::parser::matches::arg_matches::ArgMatches as cargo::util::command_prelude::ArgMatchesExt>::workspace
  10: cargo::commands::build::exec
  11: cargo::cli::main
  12: cargo::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

The problem is specific to that setup, I can't repro just by creating lib and pointing to other lib.

Steps

  1. Take https://github.com/kchibisov/winit/tree/update-wayland-rs-0.30 commit 45e643a1ea6a573bebd6afc6fca3ab9941825da1
  2. Then take https://github.com/kchibisov/client-toolkit/tree/winit-update with commit 45e643a1ea6a573bebd6afc6fca3ab9941825da1
  3. Clone them on the same level, so you'd have winit and client-toolkit.

Apply this

diff --git a/Cargo.toml b/Cargo.toml
index 1884e5d2..a1cefed8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -104,7 +104,7 @@ features = [
 ]
 
 [target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies]
-sctk = { package = "smithay-client-toolkit", git = "https://github.com/kchibisov/client-toolkit", branch = "winit-update", optional = true }
+sctk = { package = "smithay-client-toolkit", path = "../client-toolkit", branch = "winit-update", optional = true }
 wayland-client = { version = "0.30.0", optional = true }
 wayland-backend = { version = "0.1.0", default_features = false, features = ["client_system"], optional = true }
 # wayland-sys = { version = "0.30.0", default_features = false,  features = ["client", "cursor"], optional = true }

Try to build winit. You don't have to be on linux when doing so, from what I can see.

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.66.0 (d65d197ad 2022-11-15) That's from `stable` rustup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-manifestArea: Cargo.toml issuesC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions