Open IanVermes opened 6 months ago
rspm::renv_init()
is meant to be run instead of renv::init()
.
Thanks @Enchufa2 for the help.
I tried that, but unfortunately an error appears during the build, as before. The error message is identical next build.log
## Dockerfile
FROM rocker/r-base:4.2.2
RUN apt-get update -yq \
&& apt-get install -yq \
apt-file
WORKDIR /opt/example
RUN Rscript -e 'install.packages("renv"); install.packages("rspm"); rspm::renv_init(); rspm::install_sysreqs(); renv::install("units")'
Just incase there is something session based that I might be missing, I've tried to reproduce the docs https://rdrr.io/cran/rspm/man/renv_init.html, and its not possible for me.
## Dockerfile
FROM rocker/r-base:4.2.2
RUN apt-get update -yq \
&& apt-get install -yq \
apt-file
WORKDIR /opt/example
RUN Rscript -e 'install.packages("renv"); install.packages("rspm")'
docker build --progress plain -t minimal:example .
docker run --rm -it minimal:example R
Within the same R session:
rspm::renv_init()
renv::install("units@0.8-0") # <--- fails here again (same error as log)
rspm::install_sysreqs() ## never run, as previous step fails
install.packages("units") # <--- runs perfectly, rspm shims working as expected
Also, just for reference
> packageVersion("rspm")
[1] ‘0.5.2’
> packageVersion("renv")
[1] ‘1.0.7’
Mmmh... this is supposed to work:
## Dockerfile
FROM rocker/r-base:4.2.2
RUN apt-get update -yq \
&& apt-get install -yq \
apt-file
WORKDIR /opt/example
RUN Rscript -e 'install.packages(c("renv", "rspm")); rspm::renv_init()'
RUN Rscript -e 'install.packages("units")'
At least it worked at some point. But it seems that now renv
is trying to load the package after installing it? So it fails and rspm
has no chance of installing the library. I don't see any option in renv
to avoid this behavior. Maybe you could ask there?
Thank you for taking a look. This does work.
...
RUN Rscript -e 'install.packages(c("renv", "rspm")); rspm::renv_init()'
RUN Rscript -e 'install.packages("units")'
But tragically for long running scientific projects or for deterministically building docker images, version pinning of dependencies is crucial.
Pinning is not possible with install.packages
-- the use case of specifying dplyr@1.1.2
, bioc::rtracklayer@1.58.0
or from github VanLoo-lab/ascat/ASCAT@v3.1.2
is very strong and why renv::install
is preferred to install.packages
.
rspm
is such a good package and renv
is good toolkit.
That is why rspm::install_sysreqs()
is exported. You can call this function manually after any package installation. BTW, normally in a docker workflow with renv one would call restore
with a lockfile, instead of calling install
for individual packages. See this thread for reference: https://github.com/cran4linux/rspm/issues/17
Thanks @Enchufa2 - I'll test it going via the restore
route first. I'm on leave but will let you know in about 10 days.
I've been having a little trouble trying to get your package to work for me in a Docker context, and suspect it's my own misunderstanding.
Without renv I know that working without
renv
works well, as this minimal Dockerfile works perfectly:With renv
But with renv I'm doing something wrong but can't see what.
I have a small reproducible example where I try to install the
units
package withrspm
andrenv
.Then I run it as follows (Docker version 24.0.5) but fails to build:
And the logs yield the following (complete build.log attached)
While it is a very helpful error message and I could resolve the installation manually, but was hoping from the documentation that
renv::install("units@0.8-0")
followed byrspm::install_sysreqs()
would work.Please let me know what I've missed.
Our workflow revolves around
renv
andrenv::install
- so moving back toinstall.packages
wouldn't be desirable.