Build occasionally get "No such file or directory" accessing build directory
Overview
Every couple of builds (it not common but maybe 1 in 10 builds) will get an error when the runner starts:
/bin/bash: line 20: cd: /builds/GROUP/Project: No such file or directory
I am using the docker executor. Are there any ideas why occasionally this directory will not be available? Neither the build log or runner logs show anything else out of the ordinary.
Workaround
As explained in #4449 (comment 189923147) and #4449 (comment 189959431) #1379 (comment 220176045) #1379 (comment 204389790) this is because of the default content of ~/.bash_loguout
below:
if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
Proposal
MR 1523 from @ubarbaxor is currently being investigated as a potential solution for this issue. We will target the 12.7 release milestone for resolving this issue, depending on the progress made in advancing that MR.
In #4449 (closed) we are also discussing possible solutions.
Update documentation for the shell and ssh executor to make it clear that we load the user profile.
Update https://docs.gitlab.com/runner/faq/README.html to include this as a common error.