exec: "pwsh": 在 %PATH% 中找不到可执行文件

Ara*_*d S 5 gitlab-ci gitlab-ci-runner powershell-core

我一直在尝试在 gitlab CI/CD 上为演示项目启动我的管道。我已经在我的 Windows 本地机器上安装了 gitlab-runner,并将执行程序类型指定为“Shell”。我已经成功地将 gitlab-runner 与我的 gitlab 项目集成在一起。但是,每当我将任何更改推送到 repo 时,管道都会启动并最终在 %PATH 错误中找不到“pshw”。 这是我每次都会遇到的错误

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
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我解决这个问题并解释我收到此错误的原因和原因。

提前致谢

小智 68

选择 shell 选项时,gitlab runner 安装程序将用作pwsh执行程序。它生成一个config.toml看起来像

[[runners]]
  name = "some name"
  url = "http://someurl.com/"
  token = "some-token"
  executor = "shell"
  shell = "pwsh"
Run Code Online (Sandbox Code Playgroud)

问题是 pwsh 不是有效的 Windows 命令(在我的安装上)。更改pwshpowershell重新启动gitlab-runner服务解决了我的问题。


小智 23

进入GitLab Runner的安装目录,例如C:\Automation\GitLab-Runner。在这里您将看到config.toml文件,用记事本打开并替换"pwsh""powershell"如下:

从:

[[runners]]
  name = "PT-Runner"
  url = "https://gitlab.com"
  executor = "shell"
  shell = "pwsh"             # <----- change to powershell
Run Code Online (Sandbox Code Playgroud)

到:

[[runners]]
  name = "PT-Runner"
  url = "https://gitlab.com"
  executor = "shell"
  shell = "powershell"       # <----- 
Run Code Online (Sandbox Code Playgroud)


Ini*_*Ini 6

如果您不需要 Powershell Core (v7) 的功能并且可以使用 Windows Powershell (v5),则“Raghwendra Sonu”和“Not a code Monkey”的当前答案有效。如果您确实需要 Powershell Core 的功能,那么编辑您的功能config.toml并不是解决方案。

\n

我遇到了同样的问题 \xe2\x80\x94 我从 Microsoft Store 安装了 Powershell Core 并将其添加到 PATH 环境变量(自动发生),但我仍然在 gitlab 中遇到上述错误。

\n

解决方案是不使用 Microsoft Store 中的 Powershell Core,而是像这样安装它(至少对我有用):

\n
winget install --id Microsoft.Powershell --source winget\n
Run Code Online (Sandbox Code Playgroud)\n

然后通过add C:\\Program Files\\PowerShell\\7to PATH将其添加到PATH中。

\n

我希望这有帮助。

\n

  • 就是这个!非常感谢,这正是我正在寻找的。我只是一生都找不到通往 PowerShell 的路径...... (2认同)