Installation of System-Mode Runner Produces Inapropriate plist
Summary
gitlab-runner
requires $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.
- Install
gitlab-runner
12.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
gitlab-runner run
-
sudo gitlab-runner install --user root
(the user has to be provided but does not matter here) sudo gitlab-runner start
Actual behavior
Doesn't start.
Expected behavior
Starts.
Relevant logs and/or screenshots
syslog has plenty of
com.apple.xpc.launchd[1] (gitlab-runner[9457]) <Warning>: Service exited with abnormal code: 1
com.apple.xpc.launchd[1] (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
Environment description
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
respectively
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
Possible fixes
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.
Workaround
Define a user on install sudo gitlab-runner install --user someUser