GitHub 操作:在 Windows 环境 C\:\\Users\runneradmin\\.m2\repository 上缓存 Maven .m2 存储库:无法统计:没有这样的文件或目录
GitHub Actions: Cache Maven .m2 repository on Windows environment C\:\\Users\runneradmin\\.m2\repository: Cannot stat: No such file or directory
As the docs state in order to cache the Maven dependencies with GitHub Actions all we have to use is the actions/cache 像这样操作:
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify
但是使用 windows-2016
GitHub Actions 环境,这并没有为我们提供工作缓存 - as the logs states:
Post job cleanup.
"C:\Program Files\Git\usr\bin\tar.exe" --posix --use-compress-program "zstd -T0" -cf cache.tzst -P -C D:/a/spring-boot-admin/spring-boot-admin --files-from manifest.txt --force-local
/usr/bin/tar: C\:\Users\runneradmin\.m2\repository: Cannot stat: No such file or directory
/usr/bin/tar: Exiting with failure status due to previous errors
Warning: Tar failed with error: The process 'C:\Program Files\Git\usr\bin\tar.exe' failed with exit code 2
如何解决这个问题?
Maven 存储库的路径似乎未正确初始化。作为 this issue describes the paths are written with \
instead of /
which GNU tar expects. The fix was already provided in Dec 2020, so it made it to the version v2.1.4
. The last version v2.1.3
was released in November. But sadly there is a bug in pointing the v2
to the latest v2.1.4
(正如 GitHub Actions 用户通常预期的那样)。因此,要解决此问题,我们需要像这样明确指定完整的 actions/cache 版本 v2.1.4
:
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache Maven packages
uses: actions/cache@v2.1.4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify
现在它应该很有魅力了 (see logs here)。
As the docs state in order to cache the Maven dependencies with GitHub Actions all we have to use is the actions/cache 像这样操作:
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify
但是使用 windows-2016
GitHub Actions 环境,这并没有为我们提供工作缓存 - as the logs states:
Post job cleanup.
"C:\Program Files\Git\usr\bin\tar.exe" --posix --use-compress-program "zstd -T0" -cf cache.tzst -P -C D:/a/spring-boot-admin/spring-boot-admin --files-from manifest.txt --force-local
/usr/bin/tar: C\:\Users\runneradmin\.m2\repository: Cannot stat: No such file or directory
/usr/bin/tar: Exiting with failure status due to previous errors
Warning: Tar failed with error: The process 'C:\Program Files\Git\usr\bin\tar.exe' failed with exit code 2
如何解决这个问题?
Maven 存储库的路径似乎未正确初始化。作为 this issue describes the paths are written with \
instead of /
which GNU tar expects. The fix was already provided in Dec 2020, so it made it to the version v2.1.4
. The last version v2.1.3
was released in November. But sadly there is a bug in pointing the v2
to the latest v2.1.4
(正如 GitHub Actions 用户通常预期的那样)。因此,要解决此问题,我们需要像这样明确指定完整的 actions/cache 版本 v2.1.4
:
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache Maven packages
uses: actions/cache@v2.1.4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify
现在它应该很有魅力了 (see logs here)。