powershell - Github action windows runner:如何从 PATH 中删除所有 sh.exe
问题描述
在 github windows 运行器中,我需要从 PATH 中删除所有sh.exe
find 否则我的基于 Make 4.3 的构建将无法正确解析我们的 Makefile...
我目前看到 2 个解决方案来解决它:
- 从中删除所有
sh.exe
dirname 路径PATH
(即更新GITHUB_PATH
)。 - 另一种方法可能是直接删除
sh.exe
在 Windows 操作运行器中找到的任何内容。
到目前为止我测试过的都没有成功...
- 第一次尝试
- 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'.
- 尝试改用 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
解决方案
要摆脱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
推荐阅读
- php - Laravel 使用密钥解密
- ruby-on-rails - 将表单输入与 Rails 中相同表单的其他两个表单输入的结果一起保存
- ios - Xamarin - 模拟器不更新替换图像
- flutter - 具有依赖流的 Flutter Multiprovider
- python - 如何抓取嵌入 BeautifulSoup 的 pdf
- c# - Pickview 对象而不是默认键盘 Xamarin.ios
- r - 如何在 R 中使用 If 函数使用多个条件创建列
- google-cloud-platform - BigQuery Cloud Monitoring API - 400 无法写入一个或多个 TimeSeries
- json - 如何快速使用新任务恢复旧任务?
- java - 过滤Java中的重复字符