Skip to content

Fix GitHub Actions cache on Windows when the shell is Git bash - #1502

Open
rootkiller6788 wants to merge 1 commit into
google:mainfrom
rootkiller6788:fix-github-cache-gnu-tar-windows
Open

Fix GitHub Actions cache on Windows when the shell is Git bash#1502
rootkiller6788 wants to merge 1 commit into
google:mainfrom
rootkiller6788:fix-github-cache-gnu-tar-windows

Conversation

@rootkiller6788

Copy link
Copy Markdown

This one's from #1242.

#makeTarball and #extract hand absolute paths straight to tar. When a Windows runner has Git for Windows on PATH (e.g. the step shell is C:\Program Files\Git\bin\bash.EXE), GNU tar reads a drive-lettered path like D:\... as a remote host and dies with:

tar error: Cannot connect to D: resolve failed

It also treats the backslashes in the --files-from manifest as escape characters. BSD tar (the System32 one) accepts both forms, which is why this only bites when GNU tar wins the PATH race.

Change is to run tar from inside the cache temp dir with relative file names, and to write the manifest with forward slashes. Both tar flavors are fine with that, and Linux/macOS behavior is unchanged.

Verified on Windows by putting Git's tar on PATH and running the caches single file github-cache-fake test: it fails before this change and passes after.

GNU tar, the one Git for Windows puts on PATH when a step runs via
`C:\Program Files\Git\bin\bash.EXE`, treats a drive-lettered absolute path
like `D:\...` as a remote host. So saving and restoring cache tarballs
failed with:

    tar error: Cannot connect to D: resolve failed

It also reads the backslashes in the `--files-from` manifest as escape
characters. BSD tar (System32) accepted both forms.

Run tar from the cache temp dir with relative file names, and write the
manifest with forward slashes. Fixes google#1242.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant