Context
I undusted a older crate of mine and published it on GitHub and crates.io.
To keep with the style of GitHub and most new crates I renamed it to
checked-command (from checked_command) I just did a small mistake:
I forgot to rename it in the Cargo.toml name field…
The Problem
Once a crate is published with _ instead of - (or the other way around) there
is no way to fix this. Publishing a new crate with the fix won’t work, as the name
collides with the existing crate. Removing or renaming the existing crate is also
not possible as it would brake potential dependent projects.
The Actual Problem
For imports (e.g. extern crate) rust does not differ between _ and - in
crate names (it’s always _) so I was surprised to noticed that it matters
in the [dependencies] section for crates.io dependencies.
This is also a “problem” for older crates which might want to but cant update
their naming convention, as well as new users (through the other way around) which might see a extern crate some_think in the code and then get surprised, that adding a some_think dependency won’t work (as it e.g. expects some-think)
Solution
- Tread
_ / - the same in cargo allowing user to e.g. write lazy-static even through it’s actually lazy_static or some-crate even through it’s actually some_crate
- through this should not be limited to
Cargo.toml but apply to cargo+crates.io in general
- At some point maybe allow renaming
_ <->-
- this might [1] still brake dependencies for users using outdated cargo versions and support for it is, I think, less important then 1.
[1]: I don’t know enough about cargo/crate.io’s inner working to judge this
Sidenote
It might be generally a good idea to consider adding renaming support independent of this as there might be other reasons to rename a crates, e.g. trade mark problems or you noticed that the acronym/name you used has another very inappropriate meaning (e.g. sexaul meaning, racistic meaning etc.).
(note that implementing general renaming support would be noticeable more complex than _ / - support, as cargo can detect such renaming even with out being told about (e.g. seeing a crate named a-b while looking for a_b but no a_b tells cargo everything it has to know, but for general renaming cargo needs to be told what the new name is)