CARGO-LOGIN(1)

📦
version 1.99.1 · 5 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, opensuse-leap 16.0

✨ NAME ✨

cargo-login — bestie, it's literally "Log in to a registry" 💅


🎀 SYNOPSIS 🎀

cargo login [options] [-- args]

💖 DESCRIPTION 💖

Okay so picture this: you need to be that girl who's authenticated, right? This command runs a credential provider to save a token so that any command that requires authentication — like cargo-publish(1), our icon — gets automatically authenticated. No manual login arc, no drama, it just works. ✨

Everything after the two dashes (--) gets passed straight to the credential provider. Like, that's their moment, we don't touch it. 🫶

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. Standard. Cozy. 🏠

If a registry has a credential-provider specified, bestie, that one gets used. Periodt. 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, the way that it walks backwards is lowkey iconic).

The token will be read from stdin. 👀

The API token for crates.io may be retrieved from https://crates.io/me. Go get it, queen. 👑

⚠️ Take care to keep the token secret, it should not be shared with anyone else. Not your group chat, not your situationship, not anyone. It's giving private. 💀

🌸 OPTIONS 🌸

🍓 Login Options

  • --registry registry — Name of the registry to use. Registry names are defined in Cargo config files (https://doc.rust-lang.org/cargo/reference/config.html). If you don't specify it, the default registry is used, which is defined by the registry.default config key, which defaults to crates-io. So like, defaults on defaults on defaults, but it all makes sense fr fr.

🌈 Display Options

  • -v, --verbose — Use verbose output. You can specify it twice for "very verbose" output, which includes extra output such as dependency warnings and build script output. Very demure, very mindful, very verbose. 💅 May also be specified with the term.verbose config value (https://doc.rust-lang.org/cargo/reference/config.html).
  • -q, --quiet — Do not print cargo log messages. Silencing the noise, main character behavior. 🤫 May also be specified with the term.quiet config value (https://doc.rust-lang.org/cargo/reference/config.html).
  • --color when — Control when colored output is used. Valid values:
    • auto (default): Automatically detect if color support is available on the terminal. She reads the room. ✨
    • always: Always display colors. Rainbow mode, no cap. 🌈
    • never: Never display colors. Monochrome era, we respect it. 🖤

May also be specified with the term.color config value (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 (https://rust-lang.github.io/rustup/overrides.html) for more information about how toolchain overrides work. Switching toolchains like switching outfits. 👗
  • --config KEY=VALUE or PATH — Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, or provided as a path to an extra configuration file. This flag may be specified multiple times. See the command-line overrides section (https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides) for more information.
  • -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), as well as the directories searched for discovering .cargo/config.toml, for example. This option must appear before the command name, for example cargo -C path/to/my-project build.
🚨 This option is only available on the nightly channel (https://doc.rust-lang.org/book/appendix-07-nightly-rust.html) and requires the -Z unstable-options flag to enable (see #10098 https://github.com/rust-lang/cargo/issues/10098). Nightly only, bestie, don't come crying to me on stable. 😭
  • -h, --help — Prints help information. The classic. 💖
  • -Z flag — Unstable (nightly-only) flags to Cargo. Run cargo -Z help for details. Chaos mode, handle with care. 🔥

🧚 ENVIRONMENT 🧚

See the reference (https://doc.rust-lang.org/cargo/reference/environment-variables.html) for details on environment variables that Cargo reads. She's reading your env, respectfully. 👀


⭐ EXIT STATUS ⭐

  • 0: Cargo succeeded. Slay. 🎉
  • 101: Cargo failed to complete. Oof. 💀

🌟 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)


And that's the whole page, bestie — straight from the General Commands Manual, filed under CARGO-LOGIN(1). Go log in, keep that token secret, and remember: authentication is a vibe. 💅✨

📦 where this page comes from