-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Publishing, whether to crates.io or elsewhere, should be opt-in rather by on-by-default. Although rare, people do sometimes publish accidentally. Given that the default is currently to publish to crates.io publicly, this is potentially dangerous for using cargo in a corporate closed-source environment. My guess is that even most always-intended-to-be-open-source projects would rather keep things private until they're ready for some sort of release.
I see several options for making this work:
-
Havecargo new
addpublish = false
orpublish = []
or equivalent in the defaultCargo.toml
. This is probably the most minor change and I can't imagine this will break any existing uses. -
Change the behaviour so thatpublish = true
inCargo.toml
is required forcargo publish
to work, with an error message explaining this. This might break workflow for some existing projects, but it would be a very easy fix. -
Change the behaviour ofcargo publish
so that if there is nopublish = True
inCargo.toml
it interactively asks whether you're sure. Possibly with a-y
/--yes
option (a laapt install
) to automatically say "yes".
Personally, I'd prefer both 1 and 2. I'd be happy to make a PR if people like this idea.
Originally raised as an idea on #6123, but was decided it belonged as a separate issue.
Proposal as per this comment is to change the default Cargo.toml generated by cargo new
to include publish = false
with a comment pointing towards documentation about publishing.
A separate issue will be opened to cover breaking changes to behaviour to be targeted at an edition boundary.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status