From m@echler @ending from @t@t@m@th@ethz@ch  Tue May  1 16:14:43 2018
From: m@echler @ending from @t@t@m@th@ethz@ch (Martin Maechler)
Date: Tue, 1 May 2018 16:14:43 +0200
Subject: [Rd] possible internal (un)tar bug
In-Reply-To: <CABtg=K=OBTOPAwKjcb2ACHNZ1cNt8MAdwzN+F2Nn23RXetpeRg@mail.gmail.com>
References: <CABtg=K=OBTOPAwKjcb2ACHNZ1cNt8MAdwzN+F2Nn23RXetpeRg@mail.gmail.com>
Message-ID: <23272.30291.224292.957637@stat.math.ethz.ch>

>>>>> G?bor Cs?rdi <csardi.gabor at gmail.com>
>>>>>     on Tue, 1 May 2018 12:05:32 +0000 writes:

    > This is a not too old R-devel on Linux, it already fails
    > in R 3.4.4, and on macOS as well.

and fails in considerably older R versions, too.

Basically  untar() seems to fail on a connection, but works fine
on a plain file name.

This is a bug --> Thank you for the report, G?bor !

I'm investigating.
Martin

----------- my version of your reprex :

setwd(tempdir())
dir.create("pkg")
cat("this: that\n", file = file.path("pkg", "DESCRIPTION"))
tf <- "pkg_1.0.tar.gz"
tar(tf, "pkg", compression = "gzip", tar = "internal")
unlink("pkg", recursive = TRUE)

## MM: tar *file* is good
stopifnot(identical(untar(tf, list=TRUE), "pkg/DESCRIPTION"))
untar(tf, files = (f <- "pkg/DESCRIPTION")) # no problem
stopifnot(file.exists(f))
unlink("pkg", recursive = TRUE)

## Now with a connection -- "nothing works":
con <- file(tf, open = "rb"); try( untar(con, list = TRUE) ) ## -> Error
con <- file(tf, open = "rb"); try( untar(con, files = "pkg/DESCRIPTION") )
## The error message is the same in both cases:
'
Error in untar2(tarfile, files, list, exdir, restore_times) :
   incomplete block on file
'




[Rd] possible internal (un)tar bug
Martin Maechler