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

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

Closed
kchibisov opened this issue Jan 5, 2023 · 3 comments · Fixed by #11541
Closed

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

kchibisov opened this issue Jan 5, 2023 · 3 comments · Fixed by #11541
Labels
A-manifest Area: Cargo.toml issues C-bug Category: bug

Comments

@kchibisov
Copy link

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.
@ehuss
Copy link
Contributor

ehuss commented Jan 5, 2023

Thanks for the report! There are some calls to unwrap() that shouldn't have been there. I have posted #11540 to fix this.

@ehuss ehuss added A-toml Area: TOML parsing and handling A-manifest Area: Cargo.toml issues and removed A-toml Area: TOML parsing and handling labels Jan 5, 2023
@kchibisov
Copy link
Author

kchibisov commented Jan 5, 2023

You've cycled ref the issue. The PR is on #11541.

@bors bors closed this as completed in 247b22f Jan 5, 2023
@kchibisov
Copy link
Author

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-manifest Area: Cargo.toml issues C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants