Skip to content

Commit 12bd360

Browse files
committed
Use system tar on macOS / Linux for portable runtime archives
R's internal tar cannot parse PAX records that contain xattrs with embedded null bytes, which is how portable R macOS archives store Apple's com.apple.cs.CodeSignature metadata. Calling utils::untar with tar = "internal" aborts at the first such record. bsdtar (macOS) and GNU tar (Linux) both handle PAX/xattr cleanly, so fall back to Sys.which("tar") on non-Windows. Windows continues to use internal tar to dodge the long-standing Git-for-Windows GNU-tar drive-letter bug.
1 parent a238f1a commit 12bd360

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

R/install.R

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,18 @@ download_and_extract_portable_tool <- function(label, version, install_path,
5454

5555
tryCatch({
5656
ext <- tools::file_ext(temp_file)
57-
# Force R's internal tar on .gz so a system GNU tar (e.g. from Git for
58-
# Windows) doesn't misparse "C:\\..." paths as remote hosts.
5957
if (ext == "gz") {
60-
utils::untar(temp_file, exdir = install_path, tar = "internal")
58+
if (.Platform$OS.type == "windows") {
59+
# Force R's internal tar so a system GNU tar (e.g. from Git for
60+
# Windows) doesn't misparse "C:\\..." paths as remote hosts.
61+
utils::untar(temp_file, exdir = install_path, tar = "internal")
62+
} else {
63+
# Use system tar on macOS / Linux. macOS bsdtar and Linux GNU tar
64+
# both handle PAX records that include xattrs (e.g. the Apple
65+
# com.apple.cs.CodeSignature metadata in portable R archives),
66+
# which R's internal tar cannot.
67+
utils::untar(temp_file, exdir = install_path, tar = Sys.which("tar"))
68+
}
6169
} else if (ext == "zip") {
6270
utils::unzip(temp_file, exdir = install_path)
6371
} else {

0 commit comments

Comments
 (0)