Search code examples
gitlab-cigitlab-ci-runner

gitlab-runner: prepare environment failed to start process pwsh in windows


On a new WIN10 machine after installing gitlab-runner with shell executor(i.e powershell) and starting a CI build throws following error:

Preparing environment
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

  • pwsh entry for the shell attribute in gitlab-runner config.toml refers to the newer powershell(pwsh.exe) and does not come pre-installed in some WIN10 machines which contain only older powershell.exe. You can do one of following solutions:

    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