Skip to content

wslc doesn't strip \r in << redirection #40996

Description

@jdbruner

Windows Version

Microsoft Windows [Version 10.0.26300.8758]

WSL Version

wslc 2.9.3.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

No response

Distro Version

No response

Other Software

No response

Repro Steps

  1. Create a Dockerfile that uses <<xxx redirection in a RUN command and is in DOS file format (i.e., lines are terminated with \r\n)
FROM docker.io/library/debian:trixie
RUN <<EOF
set -e
touch /tmp/foo
EOF

[This is not a contrived example. Git for Windows will typically extract text files with \r\n line endings.]

  1. Attempt to build it using wslc build .

Expected Behavior

It should build successfully:

PS> wslc build -f Dockerfile.test .
Building image from directory: .

[1/2] FROM docker.io/library/debian:trixie
[2/2] RUN <<EOF (set -e...)
exporting to image
  | exporting layers
  | writing image sha256:8c80c334792040128709827780e6d1d294d6d2df127d7c23ad7e9b0446752cc4

Actual Behavior

The build fails because the command to sh in the Debian image includes carriage returns:

PS> wslc build -f Dockerfile.test .
Building image from directory: .

[1/2] FROM docker.io/library/debian:trixie
[2/2] RUN <<EOF (set -e...)
process "/bin/sh -c set -e\r\ntouch /tmp/foo\r\n" did not complete successfully: exit code: 2
  | /bin/sh: 1: set: Illegal option -
Dockerfile:2
--------------------
   1 |     FROM docker.io/library/debian:trixie
   2 | >>> RUN <<EOF
   3 | >>> set -e
   4 | >>> touch /tmp/foo
   5 | >>> EOF
   6 |
--------------------
ERROR: failed to solve: process "/bin/sh -c set -e\r\ntouch /tmp/foo\r\n" did not complete successfully: exit code: 2

Error code: E_FAIL

Diagnostic Logs

WslLogs-2026-07-04_14-45-53.tar.gz

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions