Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.
This repository was archived by the owner on May 27, 2025. It is now read-only.

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

@lucaudill

Description

@lucaudill

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions