I was doing some experiments with a new Gitlab self hosted runner on Ubuntu 22.04 LTS OS. The runner registration worked perfectly, but while running a pipeline, I faced the following error.

ERROR: Job failed: prepare environment: Process exited with status 1. 
Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading 
for more information

The error was not much descriptive and not explaining the root cause.

Solution

The Gitlab runner is configured with the default user gitlab-runner. The home directory is /home/gitlab-runner.

A file present in the home directory of the gitlab runner caused this issue. The solution is to delete the .bash_logout file from the gitlab-runner user home directory.

rm -rf /home/gitlab-runner/.bash_logout

After removing this file, rerun the pipeline. It should work.

Note: If the gitlab runner is running as a different user, you should delete this file from that user’s home directory

rm -rf /home/{gitlabuser}/.bash_logout

I hope this tip is helpful. Feel free to comment below incase of any queries or feedback.

Advertisement