尽管 "Device or resource busy" 在 GitHub 操作 Windows 工作人员上移除
Remove despite "Device or resource busy" on a GitHub Actions Windows worker
我想在将 gradle 缓存存储到 GitHub 操作之前清理它。目前相关配置如下:
- name: Turn off the Gradle Daemon
shell: bash
run: ./gradlew --stop
- name: Cleanup Gradle Cache
shell: bash
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
该过程在 Linux 和 MacOS X 下完美运行,但在 windows 上,尽管在 运行 清理之前停止了 Gradle 守护程序,但我收到以下错误:
Run rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm: cannot remove '/c/Users/runneradmin/.gradle/caches/modules-2/modules-2.lock': Device or resource busy
Error: Process completed with exit code 1.
有什么方法可以强制删除文件吗?我不关心不一致,我想删除那个文件,仅此而已。
删除必须在持续集成环境中执行,因此没有图形工具,只有 Powershell 或 git bash.
如果您可以使用 PowerShell 而不是 Bash,您可以像使用 Bash:
一样使用它
Remove-Item -Force
-Force
与 bash 的 rm
的 -f
不同(reference), but it should be OK for your problem: documentation 表示
-Force
Forces the cmdlet to remove items that cannot otherwise be changed, such as hidden or read-only files or read-only aliases or variables.
我想在将 gradle 缓存存储到 GitHub 操作之前清理它。目前相关配置如下:
- name: Turn off the Gradle Daemon
shell: bash
run: ./gradlew --stop
- name: Cleanup Gradle Cache
shell: bash
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
该过程在 Linux 和 MacOS X 下完美运行,但在 windows 上,尽管在 运行 清理之前停止了 Gradle 守护程序,但我收到以下错误:
Run rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm: cannot remove '/c/Users/runneradmin/.gradle/caches/modules-2/modules-2.lock': Device or resource busy
Error: Process completed with exit code 1.
有什么方法可以强制删除文件吗?我不关心不一致,我想删除那个文件,仅此而已。 删除必须在持续集成环境中执行,因此没有图形工具,只有 Powershell 或 git bash.
如果您可以使用 PowerShell 而不是 Bash,您可以像使用 Bash:
一样使用它Remove-Item -Force
-Force
与 bash 的 rm
的 -f
不同(reference), but it should be OK for your problem: documentation 表示
-Force
Forces the cmdlet to remove items that cannot otherwise be changed, such as hidden or read-only files or read-only aliases or variables.