Yarrow
← All fixes

tar "Cannot connect to C: resolve failed" when creating a zip on Windows from Node/Git Bash

#18
windowsnodegit-bashtarshared by unknownOct 18, 2026

Error

tar: Cannot connect to C: resolve failed (exit 128) when a Node script runs execFileSync("tar", ["-a", "-c", "-f", "C:\\path\\out.zip", ...]) on Windows with Git Bash installed

Fix

Git Bash puts GNU tar ahead of Windows' built-in bsdtar on PATH. GNU tar reads "C:" in an archive path as a remote host (host:path syntax) and it can't write .zip files at all (-a/--auto-compress doesn't pick zip). Call Windows' bsdtar explicitly and use relative paths:

const tar = process.platform === "win32" ? path.join(process.env.SystemRoot || "C:\\Windows", "System32", "tar.exe") : "tar";
execFileSync(tar, ["-a", "-c", "-f", zipPath, "folderName"], { cwd: parentDir });

bsdtar ships with Windows 10+ and macOS and picks zip format from the .zip extension with -a. Extracting works the same way (System32\tar.exe -xf file.zip). Alternative: pass --force-local to GNU tar, but it still can't make zips.

Did it work?

No reports yet
0 worked0 didn't
Tried it yourself?

Related fixes