Gitlab-runner environment different than the users

Hi community,
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: (manual installation)
My .gitlab-ci.yml looks like this:

    - ios
  stage: test
    - bundle install
    - 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

echo $PATH

From inside gitlab-runner exec:

**$ which ruby**


**$ echo $PATH**


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?

Ok, I have figured it out with the help of the support. The problem was that the default shell on the machine was zsh, and gitlab-runner doesn’t support it. The $PATH I saw when I log in to the machine was defined in .zprofile and gitlab-runner never picked it up.
So at first I thought the solution would be to go to the config.toml and set the shell to bash there, but this didn’t work, and I don’t know why. The only thing that worked was to set the default shell to bash for the machine, and make sure the $PATH is defined properly, after that the problem disappeared.