Bug: Cached zip treated as valid but yields empty archive on install
Labels: bug, cache
Description
When installing packages via pak::pak(), a cached .zip that pak reports as valid ("Cached copy … is the latest build") is later found to be an empty archive during extraction, causing a hard error. The cache lookup succeeds but the cached file is corrupt/empty, so no download is attempted and installation fails.
Steps to reproduce
pak::pak(c('jsonlite', 'rlang'))
Expected behavior
Either the cached file is validated before skipping the download (and re-downloaded if corrupt), or the error is caught and pak falls back to a fresh download automatically.
Actual behavior
pak reports the cache is fresh and skips the download, then fails during extraction with:
! C:\Users\…\jsonlite_2.0.0.zip is not a valid R package, it is an empty archive.
Error output
Error:
! error in pak subprocess
Caused by error in `verify_extracted_package(filename, pkg_cache)`:
! C:\Users\tus75918\AppData\Local\Temp\RtmpovMw7R\file431c6a465617/bin/windows/contrib/4.6/jsonlite_2.0.0.zip is not a valid R package, it is an empty archive.
Subprocess backtrace:
1. base::withCallingHandlers(...)
2. get("pkg_install_do_plan", asNamespace("pak"))(...)
3. proposal$install()
4. pkgdepends::install_package_plan(...)
5. base::withCallingHandlers({...})
6. pkgdepends:::handle_events(state, events)
7. pkgdepends:::handle_event(state, i)
8. proc$get_result()
9. processx:::process_get_result(self, private)
10. private$post_process()
11. pkgdepends:::install_extracted_binary(...)
12. pkgdepends:::verify_extracted_package(filename, pkg_cache)
13. base::throw(...)
Environment
- Platform: Windows (x86_64-w64-mingw32)
- R version: 4.6.x (inferred from contrib path)
- Packages affected: jsonlite 2.0.0, rlang 1.2.0
- Cache path:
%LOCALAPPDATA%\Temp\RtmpovMw7R\
Suggested fix
In pkgdepends:::install_extracted_binary (or the cache-hit logic upstream), validate that the cached zip is non-empty and well-formed before deciding to skip the download. If validation fails, evict the entry from the cache and re-download.
Bug: Cached zip treated as valid but yields empty archive on install
Labels: bug, cache
Description
When installing packages via
pak::pak(), a cached.zipthat pak reports as valid ("Cached copy … is the latest build") is later found to be an empty archive during extraction, causing a hard error. The cache lookup succeeds but the cached file is corrupt/empty, so no download is attempted and installation fails.Steps to reproduce
Expected behavior
Either the cached file is validated before skipping the download (and re-downloaded if corrupt), or the error is caught and pak falls back to a fresh download automatically.
Actual behavior
pak reports the cache is fresh and skips the download, then fails during extraction with:
Error output
Environment
%LOCALAPPDATA%\Temp\RtmpovMw7R\Suggested fix
In
pkgdepends:::install_extracted_binary(or the cache-hit logic upstream), validate that the cached zip is non-empty and well-formed before deciding to skip the download. If validation fails, evict the entry from the cache and re-download.