Gitlab error: pwsh”: executable file not found in %PATH%

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


Solution

Solution 1: Open a CMD or powershell window and install the newer pwsh.exe:

winget install Microsoft.PowerShell

Solution 2: Edit your config.toml to use the older powershell.exe:

From

[[runners]]
  name = "ci-runner"
  url = "http://xxx.yyy.xx/"
  token = "XXXXX"
  executor = "shell"
  shell = "pwsh"

To

[[runners]]
  name = "ci-runner"
  url = "http://xxx.yyy.xx/"
  token = "XXXXX"
  executor = "shell"
  shell = "powershell"

And then restarting gitlab-runner fixed the issue.

gitlab-runner.exe restart