Open
Description
Problem
The Cargo book explains that for cargo publish
/ cargo package
commands, the order by which it decides which registry to publish to is as follows:
--registry
CLI argpackage.publish
field inCargo.toml
if a single entry- otherwise
registry.default
key in config
However the current code checks registry.default
prior to the manifest file. This causes error like below when both registry.default
and package.publish
are specified, and no CLI arg is supplied.
% cargo package
error: `demo-registry` cannot be packaged.
The registry `crates-io` is not listed in the `package.publish` value in Cargo.toml
Steps
cargo new demo-registry
- In
.cargo/config.toml
[registry]
adddefault = "crates-io"
and some alternative registry - In
Cargo.toml
[package]
addpublish = ["some alternative registry"]
- Both
cargo package
andcargo publish
fails
Possible Solution(s)
Not sure which is the intended behavior, can either update the code or the documentation. It would be useful to let each crate's own manifest file decide the registry in a workspace setting, so switching the order in code might be better. I tried this change to move default config check after manifest infer and it now works as documented: YutaoMa#1
Notes
No response
Version
cargo 1.83.0 (5ffbef321 2024-10-29)
release: 1.83.0
commit-hash: 5ffbef3211a8c378857905775a15c5b32a174d3b
commit-date: 2024-10-29
host: aarch64-apple-darwin
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.7.1 (sys:0.4.74+curl-8.9.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w 11 Sep 2023
os: Mac OS 15.2.0 [64-bit]