Environment variable `CARGO_PKG_LICENCE` not defined

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.

It appears the field is called CARGO_PKG_LICENSE_FILE, not CARGO_PKG_LICENSE_FILE

Thanks, I'm definitively blind!

It's the U.S. spelling: "LICENSE", not the U.K. spelling "LICENCE".

2 Likes

While not set in stone, a handy rule of thumb is that computer technology will use US English rather than UK English, reflecting global US hegemony during the period in which computer technology and theory were being invented and developed (roughly 1930 - now, I'm starting the count at the moment Church and Turing were working on their Lambda Calculus and Turing Machines, respectively).

2 Likes