MacOS GitLab Runner: pwsh not in $path
Summary
When configuring a GitLab runner on Mac (10.15.7 Catalina and also tried Big Sur on another computer), the runner fails to use the Powershell Core executor. It was previously working on 13.10 with the Homebrew GitLab runner, but with the official 14.6.0 GitLab runner it cannot find 'pwsh'.
The error:
ERROR: Job failed (system failure): prepare environment: failed to start process: exec: "pwsh": executable file not found in $PATH. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information
I can open pwsh via terminal just fine and I've verified the gitlab-runner is running as my user like intended
Steps to reproduce
- Install Powershell Core via Homebrew, per Microsoft's docs
- Install the GitLab runner the official, manual way
- Register the runner
- Set the runner up as a shell runner and set the shell to 'pwsh'
- Start the runner
- Start a CICD job that uses the runner
(omitted the yml since it happens before that even gets loaded)
Actual behavior
Job fails
Expected behavior
Gitlab runner should be able to use powershell
job log for 14.6
Running with gitlab-runner 14.6.0 (5316d4ac)
on mac ()
Resolving secrets 00:00
Preparing the "shell" executor 00:00
Using Shell executor...
Preparing environment 00:00
ERROR: Job failed (system failure): prepare environment: failed to start process: exec: "pwsh": executable file not found in $PATH. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information
job log 14.7
stage: install
Running with gitlab-runner 14.7.0 (98daeee0)
on James Mac
Resolving secrets 00:00
Preparing the "shell" executor 00:00
Using Shell executor...
Preparing environment 00:02
Running on USLC02XJHC9...
Getting source from Git repository 00:13
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /Users/user/builds/<snip>/0/<snip>/.git/
Checking out e46b0ab7 as refs/merge-requests/72/head...
Removing .cache/
Removing env/
Updating/initializing submodules recursively with git depth set to 50...
Synchronizing submodule url for ''
Entering ''
Removing commonlib/__pycache__/
Entering ''
HEAD is now at 42f4a11 Merge branch 'feat/threshold' into 'main'
From https://gitlab.com/
42f4a11..e9f1d65 main -> origin/main
Submodule path '': checked out '227b10154374b487fb726b1c84078672903ef1f7'
Entering ''
Restoring cache 00:23
Version: 14.7.0
Git revision: 98daeee0
Git branch: 14-7-stable
GO version: go1.17.6
Built: 2022-01-19T17:07:00+00:00
OS/Arch: darwin/amd64
Checking cache for default...
Runtime platform arch=amd64 os=darwin pid=59660 revision=98daeee0 version=14.7.0
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted.
WARNING: env/bin/python: chmod env/bin/python: operation not permitted (suppressing repeats)
Successfully extracted cache
Executing "step_script" stage of the job script 00:08
Saving cache for successful job 01:03
Version: 14.7.0
Git revision: 98daeee0
Git branch: 14-7-stable
GO version: go1.17.6
Built: 2022-01-19T17:07:00+00:00
OS/Arch: darwin/amd64
Creating cache default...
Runtime platform arch=amd64 os=darwin pid=60137 revision=98daeee0 version=14.7.0
.cache/pip: found 787 matching files and directories
env/: found 24610 matching files and directories
No URL provided, cache will be not uploaded to shared cache server. Cache will be stored only locally.
Created cache
Cleaning up project directory and file based variables 00:01
Job succeeded
stage: test
Running with gitlab-runner 14.7.0 (98daeee0)
on James Mac
Resolving secrets 00:00
Preparing the "shell" executor 00:00
Using Shell executor...
Preparing environment 00:00
ERROR: Job failed (system failure): prepare environment: failed to start process: exec: "pwsh": executable file not found in $PATH. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information
Environment description
Using GitLab.com Shell executor with pwsh. pwsh is at /usr/local/bin/pwsh Mac OS 10.15.7 Catalina, also tested on Big Sur
config.toml contents
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = ""
url = "https://gitlab.com/"
token = ""
executor = "shell"
shell = "pwsh"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
Used GitLab Runner version
Version: 14.6.0
Git revision: 5316d4ac
Git branch: 14-6-stable
GO version: go1.13.8
Built: 2021-12-17T17:35:51+0000
OS/Arch: darwin/amd64
Version: 14.7.0
Git revision: 98daeee0
Git branch: 14-7-stable
GO version: go1.17.6
Built: 2022-01-19T17:07:00+00:00
OS/Arch: darwin/amd64
Possible fixes
Seems like the GitLab runner isn't properly reading the env variables, if I had to guess