Skip to content
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

Rename Cargo.lock #8498

Closed
Kestrer opened this issue Jul 17, 2020 · 6 comments
Closed

Rename Cargo.lock #8498

Kestrer opened this issue Jul 17, 2020 · 6 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@Kestrer
Copy link

Kestrer commented Jul 17, 2020

Cargo.lock as a name has a few problems:

  1. It doesn't play well with tab completion (as reported before in “Cargo.lock” filename is annoying because it shares a stem with “Cargo.toml” #7603).
  2. It is never edited by hand and yet it has a very user-friendly name which is similar to Cargo.toml (despite it being completely different from the user's perspective). This is potentially misleading.
  3. It doesn't have the .toml extension despite being TOML (although this doesn't matter too much).

To solve this, I recommend adding support for another name as well as Cargo.lock that will solve the above three problems. Cargo.lock will continue to be supported forever, but the new name will take precedence and cargo new will use the new name.

This new name should start with ., to emphasize that it is only used by programs and not people. Doing this will also reduce clutter in root directories as it will be hidden or tucked away at the top. It should also not drastically change the name (e.g. adding package/Lockfile etc), so that existing Rustaceans won't be confused. Something like .cargo.lock.toml, .Cargo.lock.toml or .cargo-lock.toml would be ideal.

@Kestrer Kestrer added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jul 17, 2020
@joshtriplett
Copy link
Member

With the benefit of hindsight, perhaps we would have used another name for the lockfile. (And in particular, we ideally would have used a name that ended in .toml.) But at this point, a transition would be a substantial amount of churn.

Also, I don't think we should use a hidden file for something that appears in every crate, affects the build of the crate, and will often be checked into version control. I could imagine using cargo.lock.toml, though.

Given the amount of churn this would entail, and the fact that for the foreseeable future we'd have two names rather than one, versus the amount of benefit this would provide, I don't think we should rename this file.

@Eh2406
Copy link
Contributor

Eh2406 commented Jul 17, 2020

In addition we would need a plan for the transition. One that does not have different versions of Cargo successfully building the same project but using different lockfiles.

@Kestrer
Copy link
Author

Kestrer commented Jul 17, 2020

Also, I don't think we should use a hidden file for something that appears in every crate, affects the build of the crate, and will often be checked into version control.

I think a hidden file is appropriate, since at least from the user's perspective Cargo.lock is merely an implementation detail of Cargo. Most users will never even touch it, so it makes sense to hide it. If someone tries manually editing their Cargo.lock, having it be a dotfile lets them know what they're getting in to - something that you don't have to think about in 99% of cases.

I don't see what churn this would cause. Most external Cargo tools rely on the cargo crate and don't implement Cargo.lock finding themselves. No existing crates would have to change, and new crates wouldn't even notice the difference.

@Kestrer
Copy link
Author

Kestrer commented Jul 17, 2020

One that does not have different versions of Cargo successfully building the same project but using different lockfiles.

Crates that commit their Cargo.lock would have to stick to the old system for a while to support old Cargo versions. Maybe cargo new --bin would use the old Cargo.lock for a while until everyone has updated their Cargo.

@DerSaidin
Copy link

A third issue about the same thing: #8624

Would it be possible to change this with a rust edition, such as 2024?

@weihanglo
Copy link
Member

weihanglo commented Jul 20, 2024

See #5707 (comment)

There is no plan to support different filename at this moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

5 participants