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

all files in this repository (unintentionally?) have CRLF line endings #239

Open
decathorpe opened this issue Aug 4, 2024 · 4 comments
Open

Comments

@decathorpe
Copy link

When packaging this crate for Fedora Linux as a dependency for the image crate, we found that all files that are not auto-generated by cargo during cargo publish carry CRLF line endings. This is rather unusual for Rust crates, and there is no config file to configure git to explicitly rewrite files to have CRLF line endings, so I assume this is not intentional.

@johannesvollmer
Copy link
Owner

This is correct. Not intentional. What problems exactly did it cause on Linux? Some files in particular?

@decathorpe
Copy link
Author

It's not causing "problems" per se. cargo / rustc can still read all the files. We just need to do some normalization to remove \r characters, since no files with CRLF line endings are allowed in our packages. I added a bash one-liner to fix this in a source "post-processing" step, but it would of course be better if this was fixed "at the source", especially if it's not intentional :)

@johannesvollmer
Copy link
Owner

johannesvollmer commented Aug 5, 2024

Yes, seems reasonable. Thanks for taking the time to drop by :)

@robinduerhager
Copy link

This happens most of the time during development on windows machines since windows defaults to CRLF. You might be able to prevent this by enforcing LF line endings through the configuration of e.g. EditorConfig. This will also help if some local testing or Development is transmitted to some linux based VM or Container. Additionally some .gitattributes file in the repo might be helpful so no CRLF files are pushed accidently to the repo. There is also some ready to use Rust .gitattributes file that you might want to use :). The GitHub Documentation provides a bit more info on this topic and dependencies you might have to check when using a .gitattributes file.

As of why this might be really important: I know this bug very well from the Docker / virtualization point of view. Windows can read LF just fine, however Linux often demands LF and if not provided runs into arbitrary and unexpected errors which might cost some developers a lot of time to fix 😅.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants