You bring up a lot of good points!
I’d would go for an approach which is more driven by crate authors and avoids putting any new requirements on users:
- the first time a namespaced crate is published
-
crates.io checks whether the author also owns the name in the legacy global namespace
- if true, crates.io cross-publishes the crate to both locations, with the legacy location forwarding to the new one
- afterwards, when a user of a global crate runs
cargo update, cargo will upgrade the Cargo.lock file to the new namespaced crate, using the forwarders automatically generated by the crate author
This means that other authors can publish the same crate name under their organization without any restriction, because no forwarding would happen in that case.
I would require that a file with the random string is placed at a well-known location on the requested domain, similar to how cargo login works already:
Instead of appending the crates.io-generated string to cargo login, you would just place it on the domain you want to use, and crates.io would verify it. As long as the string stays there, you own the domain.
Maven uses some notification on their website like this: https://mvnrepository.com/artifact/commons-lang/commons-lang
I imagine that more automated solutions could be found too, but I believe this would often be a manual process, especially if the original author cannot be contacted anymore.
As outlined above, this would absolutely be possible and could be automated.
With the forwarding approach I described, there would be no ambiguities at all, because it would always be clear which namespaced crate is the replacement for the global crate.
Yes, I think this would be a valid usecase for crate-rename.
I think this approach would be better than the hyphen approach. Some people even suggested that crate authors should always redefine their lib.name to strip out the namespace with the hyphen approach.
So with hyphens, you would have renames everywhere and by default; with domain namespaces you would only need renames in the unlikely event of an actual clash.