cargo: Projects created on Windows with "cargo.toml" fail to run on Linux

Problem

A project created on Windows, where the user decided to use “cargo.toml” will not run on Linux.

Steps

  1. Create a project on Windows and rename “Cargo.toml” to “cargo.toml”
  2. Attempt to “cargo run” the project on Linux.

Possible Solution(s)

I think a practical solution is for Cargo to maintain its default convention as decided in https://github.com/rust-lang/cargo/issues/45 but to read “Cargo.toml” in user friendly case insensitive way on Linux instead of warning the user that the project can’t be run on Linux (or other case sensitive systems).

This would help Linux users given that people are already doing this:

https://github.com/rust-lang/cargo/issues/45#issuecomment-1416907917

Today I searched “Why is Cargo.toml upper case.” A strange thing to search, I admit, and I’m not sure if it’s me being pedantic or nitpicky, or if it actually makes an aesthetic difference.

Either way, considering Rust promotes snake_case conventions, I too find it odd that Cargo.toml has an uppercase.

But today I also found out I can simply rename it to use a lower case and everything works. That makes me happy.

Though for the sake of convention, I’m here to put my vote for cargo.toml.

Edit: Removed opinions regarding https://github.com/rust-lang/cargo/issues/45

Notes

No response

Version

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 18 (12 by maintainers)

Most upvoted comments

Maybe for config but a lock file is generated by cargo itself and rarely, if ever, handwritten. So IMHO it doesn’t need to be checked.

Do you have a reliable way to detect case-sensitivity for paths on Windows?

Windows is case-preserving, so if we just check if path.file_name() == Some(OsStr::new("cargo.toml") and warn on that, it should be sufficient from my experience.

We shouldn’t be mutating a users project without their explicit choice. We could use cargo fix to address that.

Would it be acceptable to maintain the standard of “Cargo.html” etc as decided previously, but to read the file in a case insensitive manner instead of warn on Linux?

It could be the other kind of breaking. Users with old toolchain cannot compile new project with lowercase “cargo.toml” even it is completely compatible. External tools also need a non-trivial update for the new logic to accept “cargo.toml”. It feels like a quite large break to me.