Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

ch-image modify: improve non-existent shell error message #1913

Open
lucaudill opened this issue Jul 17, 2024 · 1 comment
Open

ch-image modify: improve non-existent shell error message #1913

lucaudill opened this issue Jul 17, 2024 · 1 comment

Comments

@lucaudill
Copy link
Collaborator

When modifying a container image with via ch-image modify using a script, we currently don't have a very user-friendly error message when trying to use a shell that doesn't exist via -S, e.g.

$ ch-image modify -S doesnotexist alpine:3.17 foo <<'EOF'
echo hello
EOF
 -1* FROM alpine:3.17
 -1. COPY ['/tmp/tmpw5_ww4op'] -> '/ch/script.sh'
updating existing image ...
 -1. RUN.S doesnotexist /ch/script.sh
/bin/sh: doesnotexist: not found
something went wrong, rolling back ...
HEAD is now at 36233bb COPY ['/tmp/tmpw5_ww4op'] -> '/ch/script.sh'
error: build failed: RUN command exited with 127

Note that we do have a user-friendly error message for this same problem in interactive mode

$ ch-image modify -S doesnotexist alpine:3.17 foo
copying image from cache ...
ch-run[169241]: error: can't execve(2): doesnotexist: No such file or directory (ch_core.c:570 2)
error: can't run shell: doesnotexist

This is because in interactive mode we rely on the return value of a ch-run subprocess to determine whether the shell is there or not, but we don't perform such a check when traversing the Dockerfile parse tree in the script case.

@reidpr
Copy link
Collaborator

reidpr commented Aug 30, 2024

The shell does tell us it’s not found, but very tersely:

/bin/sh: doesnotexist: not found

Shouldn’t the first example have a SHELL instruction though?

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

No branches or pull requests

2 participants