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

Heredocs (<<EOF) syntax in samples doesn't work on Windows when using default Git line ending settings #5402

Closed
Tracked by #5858 ...
lbussell opened this issue Apr 25, 2024 · 5 comments
Assignees

Comments

@lbussell
Copy link
Contributor

lbussell commented Apr 25, 2024

RUN <<EOF
dpkg --add-architecture amd64
apt-get update
apt-get install -y clang zlib1g-dev zlib1g-dev:amd64 gcc-x86-64-linux-gnu llvm
EOF

  1. This syntax is only used in the releasesapi samples and isn't consistent with our other samples.
  2. This syntax does not work on Windows when using Git's default "checkout with CRLF, commit LF" setting.

Proposal: Remove heredocs in samples or provide a note about this in the samples README.

Workaround: Switch the file to LF line endings using your editor before building the sample.

@richlander
Copy link
Member

I'm happy with any option. I noticed that this worked poorly on Windows when I made it was too stubborn to relent. Such surprising behavior for me.

@lbussell
Copy link
Contributor Author

Here's the issue for that - moby/buildkit#4282

@lbussell
Copy link
Contributor Author

lbussell commented May 2, 2024

[Triage] Another option is to specify the line ending for these files specifically with the .gitattributes file - e.g. https://stackoverflow.com/a/40821931

However, this could blow up if a user copies this to their repo and doesn't include the gitattributes. Since this doesn't provide a ton of value, we should just remove the Heredocs.

@lbussell lbussell removed the untriaged label May 2, 2024
@lbussell lbussell moved this from Backlog to Current Release in .NET Docker May 2, 2024
@lbussell lbussell moved this from Current Release to In Progress in .NET Docker Sep 9, 2024
@lbussell lbussell self-assigned this Sep 11, 2024
This was referenced Sep 6, 2024
@polarathene
Copy link

Collapsed as doesn't contribute much to the discussion

2. This syntax does not work on Windows when using Git's default "checkout with CRLF, commit LF" setting.

Workaround: Switch the file to LF line endings using your editor before building the sample.

Another option is to specify the line ending for these files specifically with the .gitattributes file

However, this could blow up if a user copies this to their repo and doesn't include the gitattributes. Since this doesn't provide a ton of value, we should just remove the Heredocs.

FWIW, .gitattributes has been used on projects I maintain to avoid the issue and it's been a non-problem.

That said:

  • I'm probably one of the few that builds images for such projects on Windows, whereas your demographic may very much be more likely to encounter the concern.
  • Copy/pasting examples (where editors like VSCode would default to CRLF on Windows) since there isn't as much reason to clone the repo for such, I can see why you'd want to drop the syntax (as nice as it is).

@lbussell
Copy link
Contributor Author

As you mentioned, @polarathene, the primary purpose of the samples is to be easy to run and understand. A syntax that depends on a specific line ending to work is a no-go.

These have been removed from the samples with #5882, so I'm closing the issue as complete.

@github-project-automation github-project-automation bot moved this from In Progress to Done in .NET Docker Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants