Repository navigation
Description
Previously reported in #3210, but it was closed as stale, but it is still a problem, so re-reporting it.
Minimal workflow to reproduce this:
name: GITHUB_PATH in container without PATH env
on: workflow_dispatch
jobs:
repro:
runs-on: ubuntu-latest
# rockylinux:9 as of the time of reporting
# pinning by hash, as they're about to add PATH as a workaround for this.
container: rockylinux:9@sha256:03303863808e9cd79f0c58c833db3e5f9cde9f2abe16804a267b05dc54af86e4
steps:
# works, prints Docker's default:
# /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- run: echo "$PATH"
- run: echo "/opt/dummy/bin" >> "$GITHUB_PATH"
# fails: OCI runtime exec failed: exec failed: unable to start container process:
# exec: "sh": executable file not found in $PATH
- run: echo "$PATH"If anyone wants to reproduce it themselves, you can fork my repro repo - https://github.com/Andrej730/runner-container-github-path-repro
Example failing run - https://github.com/Andrej730/runner-container-github-path-repro/actions/runs/44881647924/job/136778044524 (Current runner version: '2.338.2')
I assume when PATH was modified by the action, runner rebuilds it using image's PATH - but if PATH is missing in image, runner is not using Docker's default PATH. Which is incorrect - it does rely on default Docker path on the first step of the run, so it should also consider it later too.
Docker officially documents setting default PATH in https://docs.docker.com/engine/containers/run/#environment-variables as /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin.
Similar issue can be reproduced locally with docker run -e PATH=/opt/dummy/bin rockylinux:9 sh -c 'echo $PATH' -> OCI runtime create failed: runc create failed: unable to start container process: error during container init: exec: "sh": executable file not found in $PATH.
You can diagnose whether some image has this problem by running inspect - e.g. docker image inspect rockylinux:9 is currently missing PATH= in Config.Env, while docker image inspect ubuntu:26.04 has "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" there
Workarounds
- In Github Actions - add
PATHtoenv. So instead ofcontainer: rockylinux:9@sha256:03303863808e9cd79f0c58c833db3e5f9cde9f2abe16804a267b05dc54af86e4, use:
container:
image: rockylinux:9@sha256:03303863808e9cd79f0c58c833db3e5f9cde9f2abe16804a267b05dc54af86e4
env:
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin- For images - add
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binenv variable to the image to make it compatible with Github actions.
Activity