Where does Cargo get my name and email address when creating a project?

Working through Rust Getting started on macOS, I ran the following command for Cargo to create a project:

cargo new hello_world --bin 

When I inspected the Cargo.toml file, it contained my real name as well as my email address.

Where: Cargo gets my name and email address? How to set up the name and email address that Cargo uses?

+5
source share
1 answer

Not right: Cargo uses your git configuration, among other environment variables .

To override it, you must set the environment variables CARGO_EMAIL and CARGO_NAME when starting the load. For instance:

 CARGO_NAME=not-ross cargo new --bin project_name 

For instance:

 simon /c/rust $ CARGO_NAME=Not-Simon CARGO_EMAIL=not_simon@not _simon.com cargo new --bin override-author Created binary (application) `override-author` project simon /c/rust $ cd !$ simon /c/rust/override-author (master) $ cat Cargo.toml [package] name = "override-author" version = "0.1.0" authors = ["Not-Simon < not_simon@not _simon.com>"] [dependencies] 

Using CARGO_NAME and CARGO_EMAIL , you can cargo determine the author’s name and email address in a higher "area". If you look at the code in more detail, it will check git first, but you can override it with the --vcs flag, which will still use CARGO_NAME and CARGO_EMAIL , if provided.

+5
source

Source: https://habr.com/ru/post/1262503/


All Articles