Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Something's not right with cargo login/token migration to ~/.cargo/credentials (regression in nightly) #4199

Closed
carols10cents opened this issue Jun 21, 2017 · 4 comments

Comments

@carols10cents
Copy link
Member

carols10cents commented Jun 21, 2017

I think this is related to the changes in #3978.

I'm currently using cargo 0.21.0-nightly (50b1c24 2017-06-17).

What happened:

  • I logged in with my crates.io credentials (I change my token all the time because reasons):
cargo login [api-token]
  • I then attempted to publish a new crate to crates.io, so I ran:
cargo publish
  • I got an "unauthorized API access" error.

  • I noticed I now have ~/.cargo/config and ~/.cargo/credentials.

~/.cargo/config:

[registry]
token = "[not-the-one-i-just-used-with-cargo-login]"

~/.cargo/credentials:

token = "[api-token]"

So it looks like cargo login is now only updating ~/.cargo/credentials but cargo publish is reading from ~/.cargo/config?

This has not made it to beta yet.

@carols10cents carols10cents changed the title Something's not right with cargo login/token migration to ~/.cargo/credentials Something's not right with cargo login/token migration to ~/.cargo/credentials (regression in nightly) Jun 21, 2017
@alexcrichton
Copy link
Member

cc @dethoter, mind taking a look?

@fa7ca7
Copy link
Contributor

fa7ca7 commented Jun 21, 2017

Sure, already looking into it.

@fa7ca7
Copy link
Contributor

fa7ca7 commented Jun 21, 2017

It's my fault. The problem is in src/cargo/util/config.rs

fn load_credentials(&self, cfg: &mut ConfigValue) -> CargoResult<()> {
    ...
    registry.merge(value).chain_err(|| {

merge does nothing if a key is present in registry and value. Fixing it now.

bors added a commit that referenced this issue Jun 21, 2017
Fix an incorrect merge of credentials. Add a new test for that.

Fix for #4199.
@carols10cents
Copy link
Member Author

Just tested with cargo master (hasn't made it into the cargo shipped with nightly yet) and can confirm this is fixed! Thank you! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants