CARGO-LOGIN(1)

πŸ“¦ version 1.82.0, in ubuntu jammy, ubuntu noble

πŸ’– CARGO-LOGIN(1) πŸ’–

okay so bestie, welcome to the cargo-login page from the General Commands Manual β€” it's literally the glow-up your registry auth needed. let's get into it 🫢


✨ NAME ✨

cargo-login β€” log in to a registry πŸ”βœ¨


🌸 SYNOPSIS 🌸

cargo login [options] [token] [-- args]

πŸŽ€ DESCRIPTION πŸŽ€

okay so what this command does is run a credential provider to save a token, so that all the commands that need auth β€” like cargo-publish(1), bestie's fave β€” just get authenticated automatically. no manual work. slay. πŸ’…

everything you put after the two dashes (--) gets passed straight to the credential provider. that's their lil snack, not cargo's. πŸ“

for the default cargo:token credential provider, the token gets saved in $CARGO_HOME/credentials.toml. and CARGO_HOME defaults to .cargo in your home directory. ikyk. 🏠

if a registry has a credential-provider specified, that one gets used. otherwise, the providers from the config value registry.global-credential-providers will be attempted, starting from the end of the list (yes, from the END, that's the vibe, don't question it).

if you don't pass the token argument, it gets read from stdin. so you can pipe it in, lowkey elegant. 🌈

the API token for crates.io can be retrieved from https://crates.io/me.

⚠️ take care to keep the token secret β€” it should not be shared with anyone else. fr fr. this is your password energy, guard it with your life. πŸ™ˆπŸ”’

πŸ’… OPTIONS πŸ’…

πŸ”‘ Login Options

  • --registry registry β€” the name of the registry you wanna use. registry names are defined in Cargo config files at https://doc.rust-lang.org/cargo/reference/config.html. if you don't specify one, the default registry is used, which is defined by the registry.default config key β€” and that defaults to crates-io. πŸ‘‘

πŸ–₯️ Display Options

  • -v, --verbose β€” use verbose output. you can specify it twice for "very verbose" output, which includes extra stuff like dependency warnings and build script output. can also be set with the term.verbose config value at https://doc.rust-lang.org/cargo/reference/config.html. πŸ“’
  • -q, --quiet β€” do not print cargo log messages. can also be set with the term.quiet config value at https://doc.rust-lang.org/cargo/reference/config.html. 🀫
  • --color when β€” control when colored output is used. valid values are:
    • auto (default): automatically detect if color support is available on the terminal. πŸ”
    • always: always display colors. 🌈
    • never: never display colors. πŸ’€

can also be set with the term.color config value at https://doc.rust-lang.org/cargo/reference/config.html.

🧰 Common Options

  • +toolchain β€” if Cargo has been installed with rustup, and the first argument to cargo begins with +, it will be interpreted as a rustup toolchain name (such as +stable or +nightly). see the rustup documentation at https://rust-lang.github.io/rustup/overrides.html for more info about how toolchain overrides work. πŸ¦€
  • --config KEY=VALUE or PATH β€” overrides a Cargo configuration value. the argument should be in TOML syntax of KEY=VALUE, or given as a path to an extra configuration file. this flag may be specified multiple times. see the command-line overrides section at https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides for more info. βš™οΈ
  • -C PATH β€” changes the current working directory before executing any specified operations. this affects things like where cargo looks by default for the project manifest (Cargo.toml), and also the directories searched for discovering .cargo/config.toml, for example. this option must appear before the command name, like cargo -C path/to/my-project build.
🚨 this option is only available on the nightly channel at https://doc.rust-lang.org/book/appendix-07-nightly-rust.html and it requires the -Z unstable-options flag to enable (see #10098 at https://github.com/rust-lang/cargo/issues/10098). no stable besties allowed, sorry 😭
  • -h, --help β€” prints help information. classic. 🫢
  • -Z flag β€” unstable (nightly-only) flags to Cargo. run cargo -Z help for details. ✨

🌍 ENVIRONMENT 🌍

see the reference at https://doc.rust-lang.org/cargo/reference/environment-variables.html for the deets on environment variables that Cargo reads. 🌱


🚦 EXIT STATUS 🚦

  • 0: Cargo succeeded. πŸŽ‰
  • 101: Cargo failed to complete. 😭

⭐ EXAMPLES ⭐

  1. Save the token for the default registry:
cargo login
  1. Save the token for a specific registry:
cargo login --registry my-registry

πŸ‘€ SEE ALSO πŸ‘€

cargo(1), cargo-logout(1), cargo-publish(1)


okay and that's the whole page bestie, no notes, ate and left zero crumbs πŸ’– this was the cargo-login(1) page, straight out of the General Commands Manual β€” go log in and be the main character of your own registry, periodt. πŸ‘‘βœ¨πŸ¦‹

πŸ“¦ where this page comes from