Closed
Description
Problem
For convenience I have also uploaded the failing code here: https://github.com/bstrie/bindeperror4
For the following code:
# Cargo.toml
[package]
name = "mycrate"
version = "0.0.0"
edition = "2021"
[dependencies]
mybindep = { path = "mybindep", artifact = "bin", target = "x86_64-unknown-linux-gnu" }
// src/main.rs
fn main() {
env!("CARGO_BIN_FILE_MYBINDEP");
}
# mybindep/Cargo.toml
[package]
name = "mybindep"
version = "0.0.0"
edition = "2021"
// mybindep/src/main.rs
fn main() {}
Attempting to use cargo tree
produces the following:
thread 'main' panicked at 'activated_features for invalid package: features did not find PackageId { name: "mybindep", version: "0.0.0", source: "/home/ben/code/scrap/bindeperror4/mybindep" } NormalOrDevOrArtifactTarget(None)', src/tools/cargo/src/cargo/core/resolver/features.rs:318:14
Expand for full `cargo tree` backtrace.
thread 'main' panicked at 'activated_features for invalid package: features did not find PackageId { name: "mybindep", version: "0.0.0", source: "/home/ben/code/scrap/bindeperror4/mybindep" } NormalOrDevOrArtifactTarget(None)
Stack backtrace:
0: <anyhow::Error>::msg::<alloc::string::String>
1: <cargo::core::resolver::features::ResolvedFeatures>::activated_features_int
2: cargo::ops::tree::graph::add_pkg
3: cargo::ops::tree::graph::add_pkg
4: cargo::ops::tree::graph::build
5: cargo::ops::tree::build_and_print
6: cargo::commands::tree::exec
7: cargo::cli::main
8: cargo::main
9: std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
10: std::rt::lang_start::<()>::{closure#0}
11: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
at /rustc/de1bc0008be096cf7ed67b93402250d3b3e480d0/library/core/src/ops/function.rs:280:13
12: std::panicking::try::do_call
at /rustc/de1bc0008be096cf7ed67b93402250d3b3e480d0/library/std/src/panicking.rs:492:40
13: std::panicking::try
at /rustc/de1bc0008be096cf7ed67b93402250d3b3e480d0/library/std/src/panicking.rs:456:19
14: std::panic::catch_unwind
at /rustc/de1bc0008be096cf7ed67b93402250d3b3e480d0/library/std/src/panic.rs:137:14
15: std::rt::lang_start_internal::{{closure}}
at /rustc/de1bc0008be096cf7ed67b93402250d3b3e480d0/library/std/src/rt.rs:128:48
16: std::panicking::try::do_call
at /rustc/de1bc0008be096cf7ed67b93402250d3b3e480d0/library/std/src/panicking.rs:492:40
17: std::panicking::try
at /rustc/de1bc0008be096cf7ed67b93402250d3b3e480d0/library/std/src/panicking.rs:456:19
18: std::panic::catch_unwind
at /rustc/de1bc0008be096cf7ed67b93402250d3b3e480d0/library/std/src/panic.rs:137:14
19: std::rt::lang_start_internal
at /rustc/de1bc0008be096cf7ed67b93402250d3b3e480d0/library/std/src/rt.rs:128:20
20: main
21: <unknown>
22: __libc_start_main
23: <unknown>', src/tools/cargo/src/cargo/core/resolver/features.rs:318:14
stack backtrace:
0: rust_begin_unwind
at /rustc/de1bc0008be096cf7ed67b93402250d3b3e480d0/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/de1bc0008be096cf7ed67b93402250d3b3e480d0/library/core/src/panicking.rs:142:14
2: core::result::unwrap_failed
at /rustc/de1bc0008be096cf7ed67b93402250d3b3e480d0/library/core/src/result.rs:1785:5
3: cargo::ops::tree::graph::add_pkg
4: cargo::ops::tree::graph::add_pkg
5: cargo::ops::tree::graph::build
6: cargo::ops::tree::build_and_print
7: cargo::commands::tree::exec
8: cargo::cli::main
9: cargo::main
Curiously the panic message is very similar to the panic reported in #10431 . Since that issue has already been fixed, it's possible that the solution for this issue may be similar to the solution for that one.
Note that the following diff causes cargo tree
to run as expected:
- mybindep = { path = "mybindep", artifact = "bin", target = "x86_64-unknown-linux-gnu" }
+ mybindep = { path = "mybindep", artifact = "bin" }
So the presence of the explicit target
key is crucial here. This is similar to the circumstances of #10526 and #10525 , so it further suggests something interesting about how the target
key is being handled. It may be that fixing one of these will fix all of these.
cc @Byron
Version
cargo 1.62.0-nightly (edffc4a 2022-04-19)
release: 1.62.0-nightly
commit-hash: edffc4ada3d77799e5a04eeafd9b2f843d29fc23
commit-date: 2022-04-19
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1m)
os: Pop!_OS 21.10 (impish) [64-bit]