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

Confusion between features of multiple major versions #68

Closed
kpreid opened this issue Jan 20, 2024 · 0 comments · Fixed by #70
Closed

Confusion between features of multiple major versions #68

kpreid opened this issue Jan 20, 2024 · 0 comments · Fixed by #70
Labels
bug Something isn't working

Comments

@kpreid
Copy link

kpreid commented Jan 20, 2024

Describe the bug
When the manifest dependencies contains multiple major versions with different feature sets, krates 0.16.1 produces an internal error.

thread 'test' panicked at /Users/kpreid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krates-0.16.1/src/builder.rs:715:25:
internal error: entered unreachable code: unable to locate js for crate getrandom 0.1.16 (registry+https://github.com/rust-lang/crates.io-index) features(["bindgen", "js-sys", "wasm-bindgen"])
stack backtrace:
   0: rust_begin_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
   2: krates::builder::Builder::build_with_metadata::Node::feature_index
             at /Users/kpreid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krates-0.16.1/src/builder.rs:715:25
   3: krates::builder::Builder::build_with_metadata
             at /Users/kpreid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krates-0.16.1/src/builder.rs:1250:46
   4: krates::builder::Builder::build
             at /Users/kpreid/.cargo/registry/src/index.crates.io-6f17d22bba15001f/krates-0.16.1/src/builder.rs:572:9
   5: krates_test_case::test
             at ./src/lib.rs:7:34
   6: krates_test_case::test::{{closure}}
             at ./src/lib.rs:2:10
   7: core::ops::function::FnOnce::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
   8: core::ops::function::FnOnce::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

To Reproduce
Cargo.toml:

[package]
name = "krates-test-case"
edition = "2021"

[dependencies]
krates = "0.16.1"
# does not have a feature called wasm-bindgen
getrandom = { version = "0.2.7", features = ["js"] }
# does not have a feature called js
getrandom_old = { package = "getrandom", version = "0.1.16", features = ["wasm-bindgen"] }

Rust code (reduced from cargo_about::get_all_crates):

#[test]
fn test() {
    let mut mdc = krates::Cmd::new();
    mdc.manifest_path(<&krates::Utf8Path>::from("./Cargo.toml"));
    let mut builder = krates::Builder::new();
    builder.include_targets([("wasm32-unknown-unknown", vec![])]);
    let _graph: krates::Krates = builder.build(mdc, |_| {}).unwrap();
}

Additional context
I encountered this problem while attempting to make cargo-about use krates 0.16 to get the fix for #64. However, the bug also exists in krates@0.15.3 but not krates@0.15.1 — but this may be just because the panic was only introduced by #63.

@kpreid kpreid added the bug Something isn't working label Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant