Installation of System-Mode Runner Produces Inapropriate plist
$HOME to be set.
launchd as of macOS Catalina does not populate the environment variables when launch daemons are run as root (not documented, but it behaves like this). When installing
gitlab-runner as a service using
sudo gitlab-runner install [...], it does not specify a UserName key in the installed
/Library/LaunchDaemons/gitlab-runner.plist. This makes the UserName default to root, therefore
launchd does not populate the environment variables, therefore
gitlab-runner is missing its $HOME and fails to start.
Steps to reproduce
- Install Catalina.
gitlab-runner12.5 and its dependencies (just tested: 12.6.0~beta.2039.g9454bbff has the same problem, too) as adviced in https://docs.gitlab.com/runner/install/osx.html
- Verify it works using
sudo gitlab-runner install --user root(the user has to be provided but does not matter here)
sudo gitlab-runner start
Relevant logs and/or screenshots
syslog has plenty of
com.apple.xpc.launchd (gitlab-runner) <Warning>: Service exited with abnormal code: 1 com.apple.xpc.launchd (gitlab-runner) <Notice>: Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
If you redirect the stderr by editing the
gitlab-runner.plist you get:
FATAL: the "HOME" is not set
Darwin osxbuildbot-test 19.0.0 Darwin Kernel Version 19.0.0: Wed Oct 23 18:29:05 PDT 2019; root:xnu-6153.41.3~44/RELEASE_X86_64 x86_64 System Version: macOS 10.15.1 (19B2106) Kernel Version: Darwin 19.0.0
Used GitLab Runner version
gitlab-runner --version Version: 12.6.0~beta.2039.g9454bbff Git revision: 9454bbff Git branch: master GO version: go1.10.8 Built: 2019-11-22T15:58:59+0000 OS/Arch: darwin/amd64
gitlab-runner --version Version: 12.5.0 Git revision: 577f813d Git branch: 12-5-stable GO version: go1.13.4 Built: 2019-11-21T14:49:38+00:00 OS/Arch: darwin/amd64
You can add a UserName key to the plist whose value is not root and make the working directory and the config.toml accessible to that user and let launchd populate the environment variables. Or you can provide a $HOME using the EnvironmentVariables key in the plist.
Define a user on install
sudo gitlab-runner install --user someUser