r-lib / pak

A fresh approach to package installation
https://pak.r-lib.org
677 stars 63 forks source link

pak doesn't work with latest versions of littler in docker images #676

Open tanho63 opened 2 months ago

tanho63 commented 2 months ago

Strugglebussing while trying to upgrade rocker versions (from r-ver:4.2.3 to 4.4.1) and I think I've narrowed it down to either a pak or a littler issue:

FROM rocker/r-ver:4.4.1

RUN install2.r -e -r https://r-lib.github.io/p/pak/stable/source/linux-gnu/x86_64 pak

# littler's "r" doesn't work but somehow normal R does work ... ?
RUN r -e "pak::pkg_install('dplyr')"

returns this error on build:

[13:02:01] tan@mudkip🌊 ~/test_docker
❯ docker build .
[+] Building 3.7s (6/6) FINISHED                       docker:default
 => [internal] load build definition from Dockerfile             0.0s
 => => transferring dockerfile: 188B                             0.0s
 => [internal] load metadata for docker.io/rocker/r-ver:4.4.1    0.0s
 => [internal] load .dockerignore                                0.0s
 => => transferring context: 2B                                  0.0s
 => [1/3] FROM docker.io/rocker/r-ver:4.4.1                      0.0s
 => CACHED [2/3] RUN install2.r -e -r https://r-lib.github.io/p  0.0s
 => ERROR [3/3] RUN r -e "pak::pkg_install('dplyr')"             3.6s
------                                                                
 > [3/3] RUN r -e "pak::pkg_install('dplyr')":                        
3.581 Error:                                                          
3.581 ! error in pak subprocess                                       
3.581 Caused by error in `download.file(url, tmp, quiet = TRUE)`:     
3.581 ! could not find function "download.file"                       
3.581 ---
3.581 Backtrace:
3.581 1. pak::pkg_install("dplyr")
3.581 2. pak:::remote(function(...) get("pkg_install_make_plan", asNamespace("pak"))(...)…
3.581 3. err$throw(res$error)
3.581 ---
3.581 Subprocess backtrace:
3.581  1. base::withCallingHandlers(cli_message = function(msg) { …
3.581  2. get("pkg_install_make_plan", asNamespace("pak"))(...)
3.581  3. pkgdepends::new_pkg_installation_proposal(pkg, config = list(library = lib…
3.581  4. pkg_installation_proposal$new(refs, config = config, ...)
3.581  5. local initialize(...)
3.581  6. pkg_plan$new(refs, config = config, library = config$library, …
3.581  7. local initialize(...)
3.581  8. pkgdepends:::pkgplan_init(self, private, refs, config, library, remote_types, …
3.581  9. pkgcache::cranlike_metadata_cache$new(replica_path = private$config$get("m…
3.581 10. local initialize(...)
3.581 11. pkgcache:::cmc_init(self, private, primary_path, replica_path, platforms, …
3.581 12. pkgcache:::cmc__get_repos(repos, bioc, cran_mirror, r_version)
3.581 13. bioconductor$get_repos()
3.581 14. local get_bioc_version(getRversion(), forget)
3.581 15. local get_matching_bioc_version(r_version, forget = forget)
3.581 16. local get_version_map(forget = forget)
3.581 17. local get_yaml_config(forget)
3.581 18. base::stop(new)
3.581 19. global (function (e) …
------
Dockerfile:5
--------------------
   3 |     RUN install2.r -e -r https://r-lib.github.io/p/pak/stable/source/linux-gnu/x86_64 pak
   4 |     
   5 | >>> RUN r -e "pak::pkg_install('dplyr')"
   6 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c r -e \"pak::pkg_install('dplyr')\"" did not complete successfully: exit code: 1

This error seems to stem from https://github.com/r-lib/pak/blob/64a34ee61afa3885057fbf5dde41863549a6b3e3/src/library/pkgcache/R/bioc.R#L295 where it fails to call download.file?

tanho63 commented 2 months ago

some manual bisecting shows this works with r-ver:4.3.3 and earlier but not with r-ver:4.4.0 onward...