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

cargoHash might be different on linux and darwin systems #308089

Open
jian-lin opened this issue Apr 30, 2024 · 5 comments
Open

cargoHash might be different on linux and darwin systems #308089

jian-lin opened this issue Apr 30, 2024 · 5 comments
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin 6.topic: rust

Comments

@jian-lin
Copy link
Contributor

jian-lin commented Apr 30, 2024

Describe the bug

The cargoHash might be different on linux and darwin systems. I know that kanata, atuin and trunk-ng have this problem. There are more affected packages.

This problem seems to be caused by the case sensitivity of file systems.

Additional context

Notify maintainers

@NixOS/rust


Add a 👍 reaction to issues you find important.

@jian-lin jian-lin changed the title cargoHash is different on linux and darwin systems cargoHash might be different on linux and darwin systems Apr 30, 2024
@jian-lin jian-lin added 6.topic: rust 6.topic: darwin Running or building packages on Darwin labels Apr 30, 2024
@SuperSandro2000
Copy link
Member

buildGoModule solves a similar problem

That is an upstream feature of go and nothing nixpkgs implements.

@uri-canva
Copy link
Contributor

Note that unless cargo can resolve dependencies differently across OSs (some package managers can switch dependencies based on build os, i don't know of any that can do it based on target os, but I assume there might be, and cargo might be one of them), and the dependencies only contain source code and not outputs / intermediates, then the hashes should always be the same, and any discrepancies are likely to be due to file system case sensitivity issues, bugs in os specific code paths in cargo itself, stuff like that.

Unfortunately I don't know enough about cargo and its ecosystem to say for sure, but wanted to raise it since similar issues pop up in the maintenance of darwin support of other packages in nixpkgs, like the bazel related ones.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/cargo-lock-considered-harmful/49047/3

@jian-lin
Copy link
Contributor Author

Two related upstream issues are added.

@kornelski
Copy link

kornelski commented Aug 28, 2024

Cargo's dependency resolution is platform-independent (Cargo.lock contains the superset of all dependencies for all platforms at the same time). The crate tarballs contain only source code.

However, the tarballs are written out to the local file system by Cargo. If the tarball contains files Foo and fOO, then Cargo will make two separate files on case-sensitive file systems (usually Linux) and only one file on case-insensitive file systems (usually macOS and Windows).

There are many old packages with such error, because when Windows or macOS users had a file named cargo.toml on disk, Cargo would be able to read it as Cargo.toml it asked for, but then it would scan the directory to discover and package other files, and it would make a Linux-centric assumption that cargo.toml is a different file that hasn't been packaged yet. Same thing systematically happened with readme.md vs README.md packaged twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin 6.topic: rust
Projects
None yet
Development

No branches or pull requests

5 participants