sysreqs::sysreqs() != eval sysreqs::sysreq_commands() on rocker/rstudio:3.6.2 (and others?)
maxheld83 opened this issue · 5 comments
This installs zlib
(a dependency of, among other things {data.table}) as expected with docker build --no-cache -t reprex .
:
Dockerfile
:
# works
FROM rhub/debian-gcc-release
# does not work
# FROM rocker/rstudio:3.6.2
RUN echo "Imports: data.table" > DESCRIPTION
RUN Rscript -e "options(warn = 2); install.packages('remotes')"
RUN Rscript -e "options(warn = 2); remotes::install_github('r-hub/sysreqs')"
RUN Rscript -e "options(warn = 2); sysreqs::sysreq_commands(desc = 'DESCRIPTION', platform = 'linux-x86_64-debian-gcc')"
# next line is actually the output of above line
# but must be added manually, otherwise zlib is not installed, or at least headers are not found
# RUN export DEBIAN_FRONTEND=noninteractive; apt-get -y update && apt-get install -y zlib1g-dev
RUN Rscript -e "options(warn = 2); sysreqs::sysreqs(desc = 'DESCRIPTION', platform = 'linux-x86_64-debian-gcc')"
RUN Rscript -e "options(warn = 2); install.packages('data.table')"
however, this fails for FROM rocker/rstudio:3.6.2
, which AFAIK, is debian-gcc:
fwrite.c:10:10: fatal error: zlib.h: No such file or directory
#include <zlib.h> // for compression to .gz
^~~~~~~~
compilation terminated.
make: *** [/usr/local/lib/R/etc/Makeconf:168: fwrite.o] Error 1
ERROR: compilation failed for package ‘data.table’
* removing ‘/usr/local/lib/R/site-library/data.table’
Error in install.packages("data.table") :
(converted from warning) installation of package ‘data.table’ had non-zero exit status
Execution halted
Weirder still, the problem can be solved by manually installing zlib
with
RUN export DEBIAN_FRONTEND=noninteractive; apt-get -y update && apt-get install -y zlib1g-dev
which is the exact command which, according to sysreqs::sysreq_commands()
, sysreqs::sysreqs()
is running.
So that makes me think that the sysreqsdb entry is fine here, but something weird is going on with sysreqs::sysreqs()
.
Also paging @nuest who might have run into similar issues in containerit and @Robinlovelace who reported a similar issue in rocker-org/rocker-versioned#201.
using @jimhester's "hack" (?) from the tidverse github actions also solves the problem, though I have no idea why:
Dockerfile
:
FROM rocker/rstudio:3.6.2
RUN echo "Imports: data.table" > DESCRIPTION
# install system dependencies
RUN Rscript -e "options(warn = 2); install.packages('remotes')"
RUN Rscript -e "options(warn = 2); remotes::install_github('r-hub/sysreqs')"
ENV RHUB_PLATFORM="linux-x86_64-debian-gcc"
RUN sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))") && \
eval "$sysreqs"
# install dependencies
RUN Rscript -e "options(warn = 2); install.packages('data.table')"
sysreqs does not detect the platform, just uses the one set in the RHUB_PLATFORM
environment variable.
yes, sorry, that wasn't my problem here.
I understand that I can either set RHUB_PLATFORM
or platform = 'linux-x86_64-debian-gcc'
in the sysreqs::sysreqs()
call.
I think (?) my problem is that the below three calls do not yield the same result in the above reprex:
Rscript -e "sysreqs::sysreqs(desc = 'DESCRIPTION', platform = 'linux-x86_64-debian-gcc')"
:
does not work in above reprex: installing (e.g.) {data.table} fails withzlib.h: No such file or directory
.
({data.table} has aSystemRequirements: zlib
.)sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION', platform = 'linux-x86_64-debian-gcc'))") && eval "$sysreqs"
:
worksexport DEBIAN_FRONTEND=noninteractive; apt-get -y update && apt-get install -y zlib1g-dev
:
works, because it's the same as 2.
I had assumed that 1. would also work, but there seems to be a subtle difference between 1 and 2/3, though this difference only kicks in for rocker/rstudio:3.6.2
(and presumably other debian images?) not rhub/debian-gcc-release
.
yes, sorry, that wasn't my problem here.
Right, sorry, too quick reading. :) Yeah, sysreqs::sysreqs()
just returns the canonical names of the system requirements, not the install commands.
It probably only worked on the rhub container, because that has zlib-dev already.
Yikes, I’m so dense. Sorry about that.