Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exec: "pwsh": executable file not found in %PATH%

I've been trying to initiate my pipeline on gitlab CI/CD for a demo project. I've installed gitlab-runner in my windows local machine and gave the executor type as "Shell". And I've successfully integrated the gitlab-runner with my gitlab project. But whenever I pushed any changes to repo, the pipeline started and end up in "pshw" not found in %PATH error. This is error which I'm getting every time

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

Can anyone help me to resolve this issue and explain what and why I'm getting this error.

Thanks in advance

like image 493
Aravind S Avatar asked Jun 24 '21 03:06

Aravind S


2 Answers

When choosing the shell option, the gitlab runner installer uses pwsh as the executor. It generates a config.toml that looks like

[[runners]]
  name = "some name"
  url = "http://someurl.com/"
  token = "some-token"
  executor = "shell"
  shell = "pwsh"

The problem is that pwsh isn't a valid windows command (on my installs). Changing pwsh to powershell and restarting gitlab-runner service fixed the problem for me.

like image 148
Not a code monkey Avatar answered Oct 22 '22 00:10

Not a code monkey


Goto the installation directory of GitLab Runner e.g. C:\Automation\GitLab-Runner. Here you will see config.toml file, open with notepad and replace pwsh with powershell as below:

From:

[[runners]]
  name = "PT-Runner"
  url = "https://gitlab.com"
  executor = "shell"
  shell = **"pwsh"**

To:

[[runners]]
  name = "PT-Runner"
  url = "https://gitlab.com"
  executor = "shell"
  shell = **"powershell"**
like image 35
Raghwendra Sonu Avatar answered Oct 22 '22 01:10

Raghwendra Sonu