【问题标题】:Github action windows runner: How to remove all sh.exe from PATHGithub action windows runner:如何从 PATH 中删除所有 sh.exe
【发布时间】:2021-09-20 21:13:12
【问题描述】:

在 github windows runner 中,我需要从 PATH 中删除所有 sh.exe 查找,否则我的基于 Make 4.3 的构建将无法正确解析我们的 Makefile...

我目前看到 2 个解决方案来解决它:

  1. PATH 中删除所有sh.exe dirname 路径(即更新GITHUB_PATH)。
  2. 另一种方法是直接删除在 Windows 操作运行器中找到的任何 sh.exe

到目前为止我所测试的都没有成功...

  1. 第一次尝试
- name: Remove sh.exe from PATH
  run: set GITHUB_PATH -= "/c/Program Files/Git/bin"

错误:A positional parameter cannot be found that accepts argument '/c/Program Files/Git/bin'.

  1. 尝试改用 bash
- name: Remove sh.exe from PATH
  run: |
        echo "$PATH"
        set PATH=%PATH:C:\Program Files\Git\bin;=%
        set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
        echo "$PATH" > $GITHUB_PATH
  shell: bash

错误:line 2: =%: command not found

附件

Github 仅提供添加路径到 PATH 的示例,而不是删除路径。 参考:https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path

【问题讨论】:

    标签: powershell github-actions


    【解决方案1】:

    摆脱sh.exe(即解决方案2) 您应该尝试将以下 cmd 添加到您的 .yml 文件中:

        - name: Find sh.exe
          run: where sh
        - name: remove Git\usr\bin\sh.exe
          run: rm 'C:\Program Files\Git\usr\bin\sh.exe'
          shell: bash
        - name: remove Git\bin\sh.exe
          run: rm 'C:\Program Files\Git\bin\sh.exe'
          shell: bash
    

        - name: Clean sh.exe
          run: |
            where sh
            rm 'C:\Program Files\Git\usr\bin\sh.exe'
            rm 'C:\Program Files\Git\bin\sh.exe'
          shell: bash
    

    【讨论】:

      猜你喜欢
      • 2020-04-11
      • 2016-12-28
      • 2023-02-10
      • 2011-02-04
      • 2016-08-05
      • 2018-12-22
      • 1970-01-01
      • 2012-05-06
      • 2013-03-15
      相关资源
      最近更新 更多