Skip to content

Commit 3bbd5a5

Browse files
committed
Improve error message if publish is false or empty list
Signed-off-by: hi-rustin <[email protected]>
1 parent 071eeaf commit 3bbd5a5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/cargo/ops/registry.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,13 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
134134
let reg_name = publish_registry
135135
.clone()
136136
.unwrap_or_else(|| CRATES_IO_REGISTRY.to_string());
137-
if !allowed_registries.contains(&reg_name) {
137+
if allowed_registries.is_empty() {
138+
bail!(
139+
"`{}` cannot be published.\n\
140+
`publish` is set to `false` or an empty list in Cargo.toml and prevents publishing.",
141+
pkg.name(),
142+
);
143+
} else if !allowed_registries.contains(&reg_name) {
138144
bail!(
139145
"`{}` cannot be published.\n\
140146
The registry `{}` is not listed in the `publish` value in Cargo.toml.",

0 commit comments

Comments
 (0)