Repository navigation
SHA256 from PACKAGES is not checked against the downloaded file #145
Description
Activity
I hope at some point all CRAN repos will have secure hashes and they will be in sync with the package files as well, and then we can actually check the downloaded files, but I think we are not there yet.
For this particular issue a workaround is to switch to PPM, see the cited issues.
Or just wait a bit, since the issue is apparently already fixed on mac.r-project.org, only the mac.cran.dev front needs to invalidate its cache.
For this particular issue a workaround is to switch to PPM, see the cited issues.
Our macOS job already uses PPM (the setup-r@v2 default since r-lib/actions#1110), but PPM has no macOS binaries of adbcdrivermanager 0.24.0-3 and adbcsqlite 0.24.0-2, so pak still takes them from CRAN.
I hope at some point all CRAN repos will have secure hashes and they will be in sync with the package files as well, and then we can actually check the downloaded files, but I think we are not there yet.
The check wouldn't need to reject anything. Instead of keeping whichever download finishes first,
download_one_of()could keep the first one whose hash matches, discard mismatches and cancel the rest; if none matches, it would keep the first one, as today. A missing or out-of-date hash then costs at most the wait for the slower copy.For us this is transient, so if you think the check isn't worth it for the few cases it would catch, I'm happy to close this.
For us this is transient, so if you think the check isn't worth it for the few cases it would catch, I'm happy to close this.
No, my problem is that I am not convinced that it is doing more good than harm, because I don't trust the CRAN repos having consistent metadata. The whole reason for the fallback to the alternate server is that they have inconsistent metadata.
OTOH I don't mind making the fallback serial, i.e. first try CRAN, then mac.cran.dev. That'll solve this. Of course by the time I publish that in pak devel, the caching issue will be probably solved.....
Should be good now.
Yup, all good now (via refreshed cache). I'll keep this open in case you want to move to a fixed ordering. If not, we can close here. Thanks!
Reacted by Gábor Csárdi- added a commit that references this issue
on Sep 25, 2026
The
sha256that pkgdepends passes toasync_copy_or_add()is never compared with the download. Afterdownload_one_of()returns, it is replaced by the hash of whatever arrived:pkgcache/R/package-cache.R
Lines 275 to 282 in cd17b44
For CRAN macOS binaries,
download_one_of()races the CRAN mirror againstmac.cran.devand keeps the first to finish, so a stale file onmac.cran.devgets installed even if it does not matchPACKAGES:pkgcache/R/packages-gz.R
Lines 466 to 470 in cd17b44
This is currently the case for adbcdrivermanager 0.24.0-3 on macOS with R 4.6. Since the zstd mix-up (r-lib/pkgdepends#485, r-lib/pak#915), the file on cran.rstudio.com is gzip again and matches
PACKAGES(3b73522a…), whilemac.cran.devstill serves the zstd file (2bd7d854…). Our CI got themac.cran.devcopy and failed with "unknown archive type".A check would also need the hash parsed correctly. The
SHA256sum:field in CRAN's macOSPACKAGESis folded onto a continuation line. Base R'sread.dcf()returns the bare hash, but the parsed value here keeps the line break and indentation:Could a download that does not match the expected hash be rejected, so the other source is used instead? If that sounds reasonable, I'm happy to propose a PR.