I’m struggling to understand some of the behaviours I see when the gitlab-runner is running my jobs. I have configured the runner according to the official guide here: https://docs.gitlab.com/runner/install/osx.html (manual installation)
.gitlab-ci.yml looks like this:
test: tags: - ios stage: test before_script: - bundle install script: - bundle exec fastlane test ...
Now when I run the command in the script locally on the runner machine, as in
bundle exec fastlane test, it works fine. When I run it with
gitlab-runner exec shell test, then I get errors that the gems are missing. I tracked it down to the differences in the environment variables and tools that are being used when executing both ways, here is a summary.
My local environment on the runner machine:
which ruby /usr/local/opt/ruby/bin/ruby echo $PATH /usr/local/opt/ruby/bin:....
**$ which ruby** /usr/bin/ruby **$ echo $PATH** /usr/local/bin:/usr/bin:.....
I assumed that when the runner is configured, this is done for the user, so when I use the same user, I should have the same environment when the runner runs the script, but apparently that’s not the case. I actually believe that my trouble is in the
$PATH variable, the system ruby there is earlier in the path than the ruby installed with homebrew, so the wrong ruby without gems is picked up by the script. So the follow up question would be how to make sure that the $PATH is the same for the gitlab-runner as for the user? And actually why is it even different? I could not find it in the documentation why this should be different, the runner was supposed to use the login shell so it should pick the $PATH from the
.profile, what am I missing?