Skip to content

Add possibility to rename crates #2902

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

Closed
deeprobin opened this issue Oct 11, 2020 · 10 comments
Closed

Add possibility to rename crates #2902

deeprobin opened this issue Oct 11, 2020 · 10 comments
Labels
B-needs-rfc C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works

Comments

@deeprobin
Copy link

I would suggest that crates can be renamed. As long as no other crate has used the old name, this should be redirected to the new name.

Changes that only change the case sensitivity or the characters _ and - should also be possible. Since there are crates that have the crate names written in the wrong upper and lower case and would like to change this.

@Turbo87
Copy link
Member

Turbo87 commented Oct 11, 2020

The problem with renaming is that the crates registry is supposed to be immutable, so it would be more like a copy, not a rename.

This would generally be possible from what I can tell, but we should probably restrict people from renaming too often. It might make sense to disallow another "rename" for the next e.g. 6 months or so.

@deeprobin
Copy link
Author

deeprobin commented Oct 11, 2020

The problem with renaming is that the crates registry is supposed to be immutable, so it would be more like a copy, not a rename.

@Turbo87 Then I ask rather like this: Why is the crates repository immutable?

This would generally be possible from what I can tell, but we should probably restrict people from renaming too often. It might make sense to disallow another "rename" for the next e.g. 6 months or so.

@Turbo87 This is a good approach.

@Turbo87
Copy link
Member

Turbo87 commented Oct 11, 2020

because otherwise we'd risk breaking existing projects if dependencies could just be removed like that

@deeprobin
Copy link
Author

because otherwise we'd risk breaking existing projects if dependencies could just be removed like that

So you can set up some kind of forwarding to the new repository

@Turbo87
Copy link
Member

Turbo87 commented Oct 12, 2020

For that we would need to adjust cargo to understand such redirections, and even if we did that then users of older cargo versions would potentially get broken projects.

As I said above, the best thing we can do it copy an existing crate including all of its version to have a new name, but a proper rename is basically impossible without breaking users.

@deeprobin
Copy link
Author

@Turbo87 Thank you very much for this statement.

As I said above, the best thing we can do it copy an existing crate including all of its version to have a new name, but a proper rename is basically impossible without breaking users.

Is there a method to copy a project completely and relatively "easy"? To my knowledge there is no cargo copy or cargo clone

For that we would need to adjust cargo to understand such redirections, and even if we did that then users of older cargo versions would potentially get broken projects.

For example, you could use these redirections, but also a "legacy"-mode, which simply downloads the new cargo package when the old one is called. And new versions could then warn the end user that the package name is deprecated.

Another possibility would be to mark old names as deprecated for e.g. 12 months (during this time hopefully all packages should be updated). And afterwards you can claim the project name again. As long as it has not been claimed, it will redirect to the new project page.

@deeprobin
Copy link
Author

A small addition, as I have described above, should make it possible to change the case and I plead for the introduction of a strict case-sensitivity rule, that for example capital letters are not used.

One suggestion would be that all current crate names are converted to a crate name that complies with the rule and that all requests with the wrong case are forwarded to this name.

@deeprobin
Copy link
Author

@Turbo87 By the way, the fact that I created two basically identical issues (#2686) was not intended. I forgot that I had already created one on the same topic. In the future I will rather take care that there are no duplicate issues. I ask for your understanding.

@Turbo87
Copy link
Member

Turbo87 commented Oct 12, 2020

One suggestion would be that all current crate names are converted to a crate name that complies with the rule and that all requests with the wrong case are forwarded to this name.

AFAIK such changes would have to go through the RFC process (see https://github.com/rust-lang/rfcs/). Feel free to propose such an RFC.

Is there a method to copy a project completely and relatively "easy"? To my knowledge there is no cargo copy or cargo clone

not that I'm aware of. all of these suggestions would have to be built by someone first. (and we're all doing this in our free time... 😉)

@carols10cents
Copy link
Member

We already change all crate names to lowercase before considering uniqueness-- in other words, a crate named MyCrate and a crate named mycrate are not allowed to both exist.

In order for Cargo to use case insensitive lookup when downloading crates specified in a Cargo.toml, changes need to be made to Cargo's resolution code. That issue is rust-lang/cargo#5678.

Then there is allowing a change to a crate's canonical capitalization, which is #1451.

So, if I understand correctly, that leaves the feature request to allow renaming of crates, and if someone has the old name in their Cargo.toml and runs cargo update, to "redirect" and resolve the versions using the new name.

I do think this should go through the RFC process; I'm concerned about the perceived security angle. I think it would be quite unexpected to ask for package foo and silently get package bar. Perhaps there could be a warning saying something like "you're depending on package foo but it has been renamed to bar; change foo to bar to get future updates", but that would need a way to silence that warning if you didn't want to update... these are the sorts of details I'd want someone to explore with the community through an RFC.

So I'm closing this issue for now, pending an RFC. Thanks!

@Turbo87 Turbo87 added C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works and removed C-feature-request labels Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-needs-rfc C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works
Projects
None yet
Development

No branches or pull requests

3 participants