-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Warn when uploading a new crate with a hyphen in its name #10843
Comments
Very much agree with this. I spent hours trying to figure out whether I should name crates with hyphens or underscore and there not being an official consensus on this is pretty weird (basically everything else has a convention). Since hyphens get converted to underscores under the hood anyways, this would be a good way to guide people towards more consistent naming of crates. |
Do you mean crate names or package names? The linked RFC only speaks to crate names and not package names. I don't think I've seen a consensus that underscrores should be preferred to hyphens in package names and making cargo opinionated without more context or consensus seems premature. btw
I've been bit with this with |
Package names, my apologies. I've run into two serious headaches with these:
I also think there's a "confusability" argument to be made for progressively disallowing hyphens. |
I'm going to close, as I don't think we'll be adding a warning in the short term. There are far too many packages using hyphens, and there isn't an agreed-upon standard. People are free to pick which particular method they want, and some people strongly prefer one or the other. I think if any change is made to steer people towards one form or the other will require an RFC. This would impact a large number of users, and I suspect it just isn't worth the investment. If there are specific places where the friction could be reduced, I think it would be good to examine those without jumping to a solution first. For example I'm not entire sure I understand the two points raised. Macros shouldn't have any involvement with package names. And for the second point, I'm not really clear because crate names (in Rust) can only have underscores. I understand that the difference from a package name and the library crate name can cause some confusion. However, I think there are several other issues already covering that (such as #2775 and #6827). |
Problem
Hyphens in crate names suck for all sorts of reasons, see hyphens considered harmful. Unfortunately, cargo will happily allow you to upload a crate with a hyphen without warning.
Changing the name of crates once published appears to be effectively impossible as well.
Proposed Solution
When users are uploading a new crate, cancel the upload and warn the user if there is a hyphen in the name.
Allow users to bypass this by providing an explicit flag.
Notes
Related to #2775.
The text was updated successfully, but these errors were encountered: