$PATH available in job different to $PATH in build container (Kubernetes executor)
Summary
When echoing $PATH
in the job's script, it produces a different output than echoing $PATH
inside the build container of the running job.
This seems to occur when the Dockerfile for the build image installs software for a specific user, and the executables are in ~/.local/bin
.
$PATH
when echoing in the job script:
gitlab
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
$PATH
when echoing while exec'd into the actual build container for the same job:
[gitlab@36110ed374da /]$ echo $PATH
/home/gitlab/.local/bin:/home/gitlab/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
As a result, some software installed via pip
for that user are not accessible, as the PATH
does not contain the required directories to find the executables.
Steps to reproduce
- Have a Kubernetes executor Runner available to your project
- Create a Dockerfile like the one linked here: https://gitlab.com/tmike_ultimate_group/zd495226/zd495226/-/blob/main/Dockerfile?ref_type=heads
- Create a
.gitlab-ci.yml
file with a job to build and push the image, and a job that uses the image to echo$PATH
: https://gitlab.com/tmike_ultimate_group/zd495226/zd495226/-/blob/main/.gitlab-ci.yml?ref_type=heads
- Also has
sleep
to allow us toexec
into the build container while the job is running
- Run the job, observe output of
echo $PATH
from both the job log, and fromexec
into the build container for the job
.gitlab-ci.yml
Add the job definition that is failing here
Actual behavior
$PATH
in the build container contains /home/gitlab/.local/bin:/home/gitlab/bin:
, while $PATH
in the job does not
Expected behavior
$PATH
available in the build container should be available in the job's script
Relevant logs and/or screenshots
job log
Add the job log
Environment description
GitLab.com with Kubernetes executor runner v16.8.0
config.toml contents
Add your configuration here