Skip to content

cargo login should allow for multiple tokens, one per registry, to be saved in ~/.cargo/credentials #3365

Closed
@carols10cents

Description

@carols10cents

Because I'm working on crates.io locally and testing out publish, and because I'm interested in being able to publish to a private registry in the future, it's annoying that I have to cargo login again when I want to publish to crates.io again instead.

cargo login --help shows a --host option like cargo publish has, but specifying my local crates.io index to cargo login --host still overwrites all the content in ~/.cargo/config.

It looks like the only thing --host is used for right now is if you call cargo login without a token: println!("please visit {}me and paste the API Token below", host);

Related to rust-lang/rfcs#2141, namely, I think this is similar to, but not dependent on, #4498 so that we can say cargo login --registry myregistry and cargo will put this in .cargo/credentials, which will match up with the registry configuration in .cargo/config specified in rust-lang/rfcs#2141:

[registries.myregistry]
token = "abcdefg"

I think it could literally just append this to the file (replacing any existing token for registries.myregistry; nicer would be if it complained if registries.myregistry didn't appear in any .cargo/config.

Although I guess it does depend on #4498 to actually be useful, since otherwise cargo wouldn't know when it should use this token :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-registriesArea: registriesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-loginS-needs-mentorStatus: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.T-cargoTeam: Cargo

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions