In order to automatically add the licence field when using clap, if present in Cargo.toml, I contributed first to Cargo to add CARGO_PKG_LICENSE_FILE since only CARGO_PKG_LICENCE was previously added.
Since my PR was added to the rust 1.46 (the stable version was released on Aug 27th), it should now be possible to use both of those environment variable. So I did a quick before contributing to clap:
fn main() {
println!("{}", env!("CARGO_PKG_VERSION"));
println!("{}", env!("CARGO_PKG_LICENCE"));
println!("{}", env!("CARGO_PKG_LICENCE_FIELD"));
}
error: environment variable `CARGO_PKG_LICENCE` not defined
--> src/main.rs:5:20
|
5 | println!("{}", env!("CARGO_PKG_LICENCE"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: environment variable `CARGO_PKG_LICENCE_FIELD` not defined
--> src/main.rs:6:20
|
6 | println!("{}", env!("CARGO_PKG_LICENCE_FIELD"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
I don't understand why these environment variables are not defined.