diff --git a/earthfile2llb/converter.go b/earthfile2llb/converter.go index 0cab11aac8..41ed2751de 100644 --- a/earthfile2llb/converter.go +++ b/earthfile2llb/converter.go @@ -2559,7 +2559,7 @@ func (c *Converter) internalRun(ctx context.Context, opts ConvertRunOpts) (pllb. } } - if opts.shellWrap == nil { + if opts.shellWrap == nil && opts.WithShell { opts.shellWrap = withShellAndEnvVars } @@ -2753,7 +2753,10 @@ func (c *Converter) internalRun(ctx context.Context, opts ConvertRunOpts) (pllb. // Shell and debugger wrap. prependDebugger := !opts.Locally - finalArgs = opts.shellWrap(finalArgs, extraEnvVars, opts.WithShell, prependDebugger, isInteractive) + if opts.WithShell { + finalArgs = opts.shellWrap(finalArgs, extraEnvVars, opts.WithShell, prependDebugger, isInteractive) + } + if opts.NoCache { // llb.IgnoreCache is not always enough; we will force a different cache key as a work-around finalArgs = append(finalArgs, "#"+uuid.NewString()) diff --git a/tests/Earthfile b/tests/Earthfile index 3ed4575cdb..fdb4a47566 100644 --- a/tests/Earthfile +++ b/tests/Earthfile @@ -87,6 +87,7 @@ ga-no-qemu-group4: BUILD +end-comment BUILD +file-copying BUILD +run-no-cache + BUILD +run-exec-form-test BUILD +save-artifact-file-as-dot BUILD +save-artifact-dir-as-dot BUILD +save-artifact-force-overwrite @@ -803,6 +804,9 @@ gen-dockerfile-test: comments-test: DO +RUN_EARTHLY --earthfile=comments.earth --extra_args="--no-output" --target=+test +run-exec-form-test: + DO +RUN_EARTHLY --earthfile=run-exec-form.earth --extra_args="--no-output" --target=+test-exec-form-run + chown-test: RUN echo "test" > ./a.txt DO +RUN_EARTHLY --earthfile=chown.earth --target=+test diff --git a/tests/run-exec-form.earth b/tests/run-exec-form.earth new file mode 100644 index 0000000000..94e0b6879c --- /dev/null +++ b/tests/run-exec-form.earth @@ -0,0 +1,5 @@ +VERSION 0.8 +FROM gcr.io/distroless/python3-debian13@sha256:6a4de1cbdac6b94b74b71a33298a9c7fed918161ff686bd501bfe9454113ae58 + +test-exec-form-run: + RUN ["python3", "--version"]