CARGO-LOGIN(1)
π 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 athttps://doc.rust-lang.org/cargo/reference/config.html. if you don't specify one, the default registry is used, which is defined by theregistry.defaultconfig key β and that defaults tocrates-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 theterm.verboseconfig value athttps://doc.rust-lang.org/cargo/reference/config.html. π’-q,--quietβ do not print cargo log messages. can also be set with theterm.quietconfig value athttps://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 tocargobegins with+, it will be interpreted as a rustup toolchain name (such as+stableor+nightly). see the rustup documentation athttps://rust-lang.github.io/rustup/overrides.htmlfor more info about how toolchain overrides work. π¦--config KEY=VALUE or PATHβ overrides a Cargo configuration value. the argument should be in TOML syntax ofKEY=VALUE, or given as a path to an extra configuration file. this flag may be specified multiple times. see the command-line overrides section athttps://doc.rust-lang.org/cargo/reference/config.html#command-line-overridesfor 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, likecargo -C path/to/my-project build.
π¨ this option is only available on the nightly channel athttps://doc.rust-lang.org/book/appendix-07-nightly-rust.htmland it requires the-Z unstable-optionsflag to enable (see #10098 athttps://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. runcargo -Z helpfor 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 β
- Save the token for the default registry:
cargo login
- 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
- ubuntu jammy: cargo-1.80 1.80.1+dfsg0ubuntu1~bpo0-0ubuntu0.22.04.1 Β· Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.80 1.80.1+dfsg0ubuntu1-0ubuntu0.24.04.01 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms