eddelbuettel / r2u

CRAN as Ubuntu Binaries
https://eddelbuettel.github.io/r2u
240 stars 16 forks source link

Can't install sf #17

Closed pokyah closed 2 years ago

pokyah commented 2 years ago

Hi !

Thanks for this great piece of software. I'm using it to build a custom docker image to ensure a standard & reproducible working environment. So far I can configure my dockerfile to pre-install the required packages.

Everything works as expected and once I'm into my container I can also install new packages thanks to bpsm using install.packages("<pkg_name>") or directly from terminal using sudo apt-get install r-cran-<pkg_name>.

However if I try to install package sf from my container I get an error :

$ sudo apt-get install r-cran-sf
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 r-cran-sf : Depends: libgdal29 (>= 3.3.0) but it is not installable
             Depends: libgeos-c1v5 (>= 3.9.0) but it is not going to be installed
             Depends: libproj19 (>= 7.1.0) but it is not installable
E: Unable to correct problems, you have held broken packages.

From your documentation I can see that there was an issue with sf and that it was solved :

  • [DONE] Both sf and terra needed a dependency adjustment on 'focal' for their most recent versions.

But I don't see what should I do in order to allow sf to be installed?

Here is an excerpt of the dockerfile used to build the container:

ARG r_version="4.2.1"
ENV R_VERSION=${r_version}
ENV R_BASE_VERSION=${R_VERSION}

USER 0 
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        software-properties-common \
                dirmngr \
                ed \
        less \
        locales \
        vim-tiny \
        wget \
        ca-certificates \
        && add-apt-repository --enable-source --yes "ppa:marutter/rrutter4.0" \
        && add-apt-repository --enable-source --yes "ppa:c2d4u.team/c2d4u4.0+"

RUN apt-get update \
        && apt-get install -y --no-install-recommends \
                 littler \
        r-base=${R_BASE_VERSION}-* \
        r-base-dev=${R_BASE_VERSION}-* \
        r-base-core=${R_BASE_VERSION}-* \
        r-recommended=${R_BASE_VERSION}-* \
                 r-cran-docopt \
    && ln -s /usr/lib/R/site-library/littler/examples/install.r /usr/local/bin/install.r \
    && ln -s /usr/lib/R/site-library/littler/examples/install2.r /usr/local/bin/install2.r \
    && ln -s /usr/lib/R/site-library/littler/examples/installGithub.r /usr/local/bin/installGithub.r \
    && ln -s /usr/lib/R/site-library/littler/examples/testInstalled.r /usr/local/bin/testInstalled.r \
    && rm -rf /tmp/downloaded_packages/ /tmp/*.rds \
    && rm -rf /var/lib/apt/lists/*

RUN add-apt-repository --yes "ppa:edd/r-4.0" \
    && apt-get install -y --no-install-recommends \
                sudo \
                r-cran-bspm \
        && echo "suppressMessages(bspm::enable())" >> /etc/R/Rprofile.site \
        && echo "options(bspm.sudo=TRUE)" >> /etc/R/Rprofile.site \
        && echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/90local-no-recommends \
        && echo "docker ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/local-docker-user \
        && chmod 0440 /etc/sudoers.d/local-docker-user \
        && chgrp 1000 /usr/local/lib/R/site-library \
        && install.r remotes

and the session info from within my container :

> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] timetk_2.8.1    lubridate_1.8.0 R6_2.5.1       

loaded via a namespace (and not attached):
 [1] zoo_1.8-10         tidyselect_1.1.2   purrr_0.3.4        listenv_0.8.0     
 [5] splines_4.2.1      bspm_0.3.10        lattice_0.20-45    colorspace_2.0-3  
 [9] vctrs_0.4.1        generics_0.1.3     rsample_1.1.0      utf8_1.2.2        
[13] survival_3.4-0     prodlim_2019.11.13 rlang_1.0.5        pillar_1.8.1      
[17] glue_1.6.2         withr_2.5.0        lifecycle_1.0.2    lava_1.6.10       
[21] timeDate_4021.104  munsell_0.5.0      gtable_0.3.1       future_1.28.0     
[25] recipes_1.0.1      codetools_0.2-18   parallel_4.2.1     class_7.3-20      
[29] fansi_1.0.3        furrr_0.3.1        xts_0.12.1         Rcpp_1.0.9        
[33] scales_1.2.1       ipred_0.9-13       parallelly_1.32.1  ggplot2_3.3.6     
[37] digest_0.6.29      dplyr_1.0.10       grid_4.2.1         hardhat_1.2.0     
[41] cli_3.4.0          tools_4.2.1        magrittr_2.0.3     tibble_3.1.7      
[45] tidyr_1.2.1        future.apply_1.9.1 pkgconfig_2.0.3    MASS_7.3-58.1     
[49] ellipsis_0.3.2     Matrix_1.5-1       gower_1.0.0        rstudioapi_0.14   
[53] globals_0.16.1     rpart_4.1.16       nnet_7.3-17        compiler_4.2.1   

Thanks for your support.

Best regards!

eddelbuettel commented 2 years ago

The geospatial packages are known tricky because of the libraries and build drift. If you can, consider 22.04 aka "jammy" which is better.

As for focal, I just did

edd@rob:~$ docker run --rm -ti eddelbuettel/r2u:20.04                                                                                                                                                              
root@df7a711744a4:/# install.r sf                                                                                                                                                                                  
Install system packages as root...                                                                                                                                                                                 
Reading package lists... Done                                                                                                                                                                                      
Building dependency tree                                                                                                                                                                                           
Reading state information... Done                                                                                                                                                                                  
Ign https://r2u.stat.illinois.edu/ubuntu focal InRelease                                                                                                                                                           
Get:1 https://r2u.stat.illinois.edu/ubuntu focal Release [5713 B]                                                                                                                                                  
Get:2 https://r2u.stat.illinois.edu/ubuntu focal Release.gpg [793 B]                                                                                                                                               
Get:3 https://r2u.stat.illinois.edu/ubuntu focal/main amd64 Packages [2147 kB]                                                                                                                                     
Get:4 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal InRelease [18.1 kB]                                                                                                                               
Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]                                                                                                                                          
Hit http://archive.ubuntu.com/ubuntu focal InRelease                                                                                                                                                               
Get:6 https://r2u.stat.illinois.edu/ubuntu focal/main all Packages [6654 kB]                                                                                                                                       
Get:7 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]                                                                                                                                            
Get:8 http://ppa.launchpad.net/edd/misc/ubuntu focal InRelease [18.1 kB]                                                                                                                                           
Get:9 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]                                                                                                                                         
Get:10 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [2139 kB]                                                                                                                              
Hit http://ppa.launchpad.net/edd/r-4.0/ubuntu focal InRelease                                                                                                                                                      
Get:11 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [1654 kB]                                                                                                                          
Get:12 http://ppa.launchpad.net/marutter/rrutter4.0/ubuntu focal InRelease [17.5 kB]                                                                                                                               
Get:13 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1200 kB]                                                                                                                            
Get:14 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [903 kB]                                                                                                                           
Get:15 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal/main amd64 Packages [1060 kB]                                                                                                                   
Get:16 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [30.2 kB]                                                                                                                          
Get:17 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [2631 kB]                                                                                                                                
Get:18 http://ppa.launchpad.net/edd/misc/ubuntu focal/main amd64 Packages [16.6 kB]                                                                                                                                
Get:19 http://ppa.launchpad.net/marutter/rrutter4.0/ubuntu focal/main amd64 Packages [8895 B]                                                                                                                      
Fetched 18.8 MB in 0s (0 B/s)                                                                                                                                                                                     
Reading package lists... Done                                                                                                                                                                                      
Building dependency tree                                                                                                                                                                                           
Reading state information... Done                                                                                                                                                                                  
Get:1 https://r2u.stat.illinois.edu/ubuntu focal/main amd64 r-cran-proxy amd64 0.4-27-1.ca2004.1 [169 kB]                                                                                                         
Get:2 https://r2u.stat.illinois.edu/ubuntu focal/main amd64 r-cran-e1071 amd64 1.7-11-1.ca2004.1 [547 kB] 
[.... lots of other lines omitted ...]
Setting up odbcinst (2.3.6-0.1build1) ...
Setting up libgdal26 (3.0.4+dfsg-1build3) ...
Setting up r-cran-sf (1.0-8-1.ca2004.1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
root@df7a711744a4:/# 
root@df7a711744a4:/# R

R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(sf)
Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1; sf_use_s2() is TRUE
> 

so I can only urge you to study the documentation more closely (maybe you missed pinning?) as this clearly works.

Just for added benefit, I see

root@df7a711744a4:/# apt-cache policy r-cran-sf
r-cran-sf:
  Installed: 1.0-8-1.ca2004.1
  Candidate: 1.0-8-1.ca2004.1
  Version table:
 *** 1.0-8-1.ca2004.1 700
        700 https://r2u.stat.illinois.edu/ubuntu focal/main amd64 Packages
        100 /var/lib/dpkg/status
     1.0-7-1cran1.2004.0 500
        500 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal/main amd64 Packages
     0.8-0+dfsg-1ubuntu3 500
        500 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
root@df7a711744a4:/# 
pokyah commented 2 years ago

Thanks for your quick reply @eddelbuettel,

Okay. I've got it now. I had to add the following lines to my dockerfile :

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A1489FE2AB99A21A
RUN echo "deb [arch=amd64] https://r2u.stat.illinois.edu/ubuntu focal main" > /etc/apt/sources.list.d/cranapt.list
RUN apt update

Doing so the installation of sf from withing my container works out of the box.

best regards