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

name is documented to default to the crate name, but it defaults to the package name #4934

Closed
2 tasks done
Nemo157 opened this issue May 23, 2023 · 1 comment
Closed
2 tasks done
Labels
C-bug Category: Updating dependencies

Comments

@Nemo157
Copy link
Contributor

Nemo157 commented May 23, 2023

Please complete the following tasks

Rust Version

rustc 1.71.0-nightly (9d871b061 2023-05-21)

Clap Version

4.3.0

Minimal reproducible code

[package]
name = "foo"
version = "0.1.0"
edition = "2021"

[dependencies]
clap = { version = "4.3.0", features = ["derive"] }

[[bin]]
name = "bar"
path = "src/main.rs"
use clap::Parser;

#[derive(Parser)]
#[command(version)]
struct Args {}

fn main() {
  Args::parse();
}

Steps to reproduce the bug with the above code

cargo run -- --version

Actual Behaviour

see context

Expected Behaviour

see context

Additional Context

clap/src/_derive/mod.rs

Lines 143 to 144 in 944556e

//! - `name = <expr>`: [`Command::name`][crate::Command::name]
//! - When not present: [crate `name`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-name-field) (if on [`Parser`][crate::Parser] container), variant name (if on [`Subcommand`][crate::Subcommand] variant)
states that when not present the "crate name" will be used, but links to the "package name" field.

let pkg_name = std::env::var("CARGO_PKG_NAME").ok().unwrap_or_default();
uses CARGO_PKG_NAME instead of CARGO_CRATE_NAME.

There's some confusion in the ecosystem about what a "crate" is, I think it's important to be careful to not perpetuate this misunderstanding in documentation.

Debug Output

No response

@Nemo157 Nemo157 added the C-bug Category: Updating dependencies label May 23, 2023
@epage epage closed this as completed in 777e4dc May 23, 2023
@epage
Copy link
Member

epage commented May 23, 2023

There's some confusion in the ecosystem about what a "crate" is, I think it's important to be careful to not perpetuate this misunderstanding in documentation.

Agreed. I don't think I knew the difference until being on the cargo team for a while

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Updating dependencies
Projects
None yet
Development

No branches or pull requests

2 participants