Skip to content

fix(evals): build /run.sh with printf so legacy builder works#2779

Merged
hamza-jeddad merged 1 commit into
mainfrom
fix-evals-runsh-legacy-builder
May 13, 2026
Merged

fix(evals): build /run.sh with printf so legacy builder works#2779
hamza-jeddad merged 1 commit into
mainfrom
fix-evals-runsh-legacy-builder

Conversation

@hamza-jeddad

@hamza-jeddad hamza-jeddad commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

pkg/evaluation/Dockerfile.template used a BuildKit heredoc to write /run.sh:

RUN cat <<-'EOF' >/run.sh
#!/usr/bin/env sh
set -euo pipefail
exec "$@"
EOF

Heredocs require BuildKit. When the build runs against the legacy builder, this is parsed as just RUN cat >/run.shcat reads from empty stdin and produces a zero-byte /run.sh. The subsequent heredoc body lines are treated as standalone Dockerfile instructions; Docker is lenient and the build "succeeds" with /run.sh empty but executable.

Replaced with a single printf that works on both legacy and BuildKit builders:

RUN printf '#!/usr/bin/env sh\nset -euo pipefail\nexec "$@"\n' > /run.sh && chmod +x /run.sh

Resulting /run.sh is byte-identical to what the heredoc produces under BuildKit.

exec /run.sh: exec format error

The Dockerfile.template used a BuildKit heredoc (`RUN cat <<-'EOF' >/run.sh`).
With the legacy builder it parses as `RUN cat >/run.sh` — empty stdin, 0-byte
file. Every eval container then dies with `exec /run.sh: exec format error`,
emits no events, and the run ends with Total Cost=$0 / Errors=N/N.

Replace the heredoc with a single `RUN printf … > /run.sh && chmod +x`.
Same resulting file, works on both legacy builder and BuildKit.
@hamza-jeddad hamza-jeddad requested a review from a team as a code owner May 13, 2026 11:43

@docker-agent docker-agent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

This is a clean, well-scoped fix. The heredoc → printf replacement correctly addresses the legacy builder compatibility issue described in the PR. No bugs were found in the changed code.

Summary of changes reviewed:

  • pkg/evaluation/Dockerfile.template: Replaces a BuildKit-only heredoc with a POSIX-compatible printf command to write /run.sh, ensuring the file is populated correctly when the legacy builder is used.

The fix is byte-identical in output to the original heredoc under BuildKit, and the added chmod +x is a safe no-op on a file that was already executable under the heredoc approach.

@hamza-jeddad hamza-jeddad merged commit 7da23ee into main May 13, 2026
11 of 12 checks passed
@hamza-jeddad hamza-jeddad deleted the fix-evals-runsh-legacy-builder branch May 13, 2026 11:52
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

Successfully merging this pull request may close these issues.

3 participants