Skip to content

Introduce Credentials#33

Open
nox wants to merge 1 commit intotaiki-e:mainfrom
nox:credentials
Open

Introduce Credentials#33
nox wants to merge 1 commit intotaiki-e:mainfrom
nox:credentials

Conversation

@nox
Copy link
Copy Markdown
Contributor

@nox nox commented Jun 13, 2025

This new struct reads from .cargo/credentials.toml

This new struct reads from .cargo/credentials.toml
@nox
Copy link
Copy Markdown
Contributor Author

nox commented Jun 13, 2025

I read through Cargo's code and AFAICT .cargo/credentials.toml takes precedence over whatever is found in .cargo/config.toml, but env variables still have the strongest preference. I'm not sure whether we want to directly read .cargo/credentials.toml when using Config::load so I just introduced new structs without changing how config files are read.

@taiki-e
Copy link
Copy Markdown
Owner

taiki-e commented Jun 22, 2025

Thanks for the PR!

Is it possible to add a test?

I read through Cargo's code and AFAICT .cargo/credentials.toml takes precedence over whatever is found in .cargo/config.toml, but env variables still have the strongest preference. I'm not sure whether we want to directly read .cargo/credentials.toml when using Config::load so I just introduced new structs without changing how config files are read.

I think not reading the .cargo/credentials.toml by default is a reasonable decision considering users who do not need credentials.

That said, it might be a bit annoying for users who need credentials, as they would have to manually emulate Cargo's processing there. I think the more preferred option here would be one of the following (although it would require a breaking change).

  • Put the credentials related fields behind the Cargo feature (i.e., make them optional) and do the complete process including loading .cargo/credentials.toml when the feature is enabled.
  • Change load_with_options to take a struct and add an option to choose whether to read .cargo/credentials.toml.

The breaking change to load_with_options is something that being considered for #3 anyway, and given that it has been over 2 years since the 0.1.0 release, there is no problem to release 0.2.0 with breaking changes.

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

Successfully merging this pull request may close these issues.

2 participants