rstudio / packrat

Packrat is a dependency management system for R
http://rstudio.github.io/packrat/
402 stars 90 forks source link

Update `renv` to latest dev version #718

Closed toph-allen closed 1 year ago

toph-allen commented 1 year ago

This PR updates renv to the latest dev version, https://github.com/rstudio/renv/commit/42c22c01d3bc02968b52d2049dcef17e49b5b29a. This includes the commit that should fix #716.

toph-allen commented 1 year ago

I guess to test this I'd try to run packrat::restore() on a project that includes a dependency on box?

aronatkins commented 1 year ago

@toph-allen - yes, that sounds right - installing box using packrat from Package Manager as a binary package (Linux). we should also re-validate https://github.com/rstudio/packrat/pull/713

toph-allen commented 1 year ago

Re-validating #713:

Dockerfile.packrat

FROM rstudio/r-base:4.3.0-jammy AS base

RUN apt-get update && apt-get -y install pkg-config

ARG REPOSITORY=https://packagemanager.rstudio.com/cran/__linux__/jammy/latest
RUN echo "options(repos = c(CRAN = '${REPOSITORY}'))" >> /opt/R/4.3.0/lib/R/etc/Rprofile.site

RUN R -s -e "install.packages('remotes')"

FROM base as setup

ARG PACKRAT_REF="toph-update-renv-2023-08-09"
RUN R -s -e "remotes::install_github('rstudio/packrat', '${PACKRAT_REF}')"

FROM setup AS installation

RUN mkdir /content \
    && echo "library(rjags)" > /content/script.R \
    && echo "options(download.file.method = 'curl', download.file.extra = paste('-s -L -f -A ', shQuote(getOption('HTTPUserAgent'))))" > /content/.Rprofile

WORKDIR /content

ENV RENV_INSTALL_TEST_LOAD=True

RUN R -s -e "packrat::init(enter = FALSE, infer.dependencies = FALSE)"
# install by R of rjags into the packrat library..
RUN R -s -e "install.packages('rjags')"
RUN R -s -e "packrat::snapshot()"
RUN rm -rf packrat/lib* packrat/src
# installation by packrat of rjags into the packrat library.
RUN R -s -e "packrat::restore()"
RUN R -s -f "script.R"
$ docker build --progress=plain --no-cache-filter=setup -f Dockerfile.packrat .
 > [installation 7/8] RUN R -s -e "packrat::restore()":
11.73 ================================================================================
11.73
11.73 Error: .onLoad failed in loadNamespace() for 'rjags', details:
11.73   call: dyn.load(file, DLLpath = DLLpath, ...)
11.73   error: unable to load shared object '/content/packrat/lib/x86_64-pc-linux-gnu/4.3.0/rjags/libs/rjags.so':
11.73   libjags.so.4: cannot open shared object file: No such file or directory
11.73 Execution halted
11.73
11.73 Error: error testing if 'rjags' can be loaded [error code 1]
11.74 Execution halted

Dockerfile.packrat-crosswired

FROM rstudio/r-base:4.3.0-bionic AS base

RUN apt-get update && apt-get -y install pkg-config

ARG REPOSITORY=https://packagemanager.rstudio.com/cran/__linux__/bionic/latest
RUN echo "options(repos = c(CRAN = '${REPOSITORY}'))" >> /opt/R/4.3.0/lib/R/etc/Rprofile.site

RUN R -s -e "install.packages('remotes')"

FROM base as setup

ARG PACKRAT_REF="toph-update-renv-2023-08-09"
RUN R -s -e "remotes::install_github('rstudio/packrat', '${PACKRAT_REF}')"

FROM setup AS installation

RUN mkdir /content \
    && echo "library(fastmap)" > /content/script.R \
    && echo "options(download.file.method = 'curl', download.file.extra = paste('-s -L -f -A ', shQuote(getOption('HTTPUserAgent'))))" > /content/.Rprofile

WORKDIR /content

ENV RENV_INSTALL_TEST_LOAD=True

RUN R -s -e "packrat::init(enter = FALSE, infer.dependencies = FALSE)"
# install by R of fastmap into the packrat library..
RUN R -s -e "install.packages('fastmap')"
RUN R -s -e "packrat::snapshot()"
RUN rm -rf packrat/lib* packrat/src
# installation by packrat of fastmap into the packrat library using a BAD repository
ARG JAMMY_REPOSITORY=https://packagemanager.rstudio.com/cran/__linux__/jammy/latest
RUN R -s -e "packrat::set_lockfile_metadata(repos = c(CRAN = '${JAMMY_REPOSITORY}'))"
RUN R -s -e "packrat::restore()"
RUN R -s -f "script.R"
$ docker build --progress=plain --no-cache-filter=setup -f Dockerfile.packrat-crosswired .
 > [installation 8/9] RUN R -s -e "packrat::restore()":
3.388 ================================================================================
3.388
3.388 Error in dyn.load(file, DLLpath = DLLpath, ...) :
3.388   unable to load shared object '/content/packrat/lib/x86_64-pc-linux-gnu/4.3.0/fastmap/libs/fastmap.so':
3.388   /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /content/packrat/lib/x86_64-pc-linux-gnu/4.3.0/fastmap/libs/fastmap.so)
3.388 Calls: loadNamespace -> library.dynam -> dyn.load
3.388 Execution halted
3.388
3.388 Error: error testing if 'fastmap' can be loaded [error code 1]
3.389 Execution halted
toph-allen commented 1 year ago

@aronatkins ~It looks like test-loading box still fails.~

[EDIT] Oops that's the final script loading it that fails, which is expected. 😂

The part that needs to work works.

Dockerfile.packrat-box

FROM rstudio/r-base:4.3.0-jammy AS base

RUN apt-get update && apt-get -y install pkg-config

ARG REPOSITORY=https://packagemanager.rstudio.com/cran/__linux__/jammy/latest
RUN echo "options(repos = c(CRAN = '${REPOSITORY}'))" >> /opt/R/4.3.0/lib/R/etc/Rprofile.site

RUN R -s -e "install.packages('remotes')"

FROM base as setup

ARG PACKRAT_REF="toph-update-renv-2023-08-09"
RUN R -s -e "remotes::install_github('rstudio/packrat', '${PACKRAT_REF}')"

FROM setup AS installation

RUN mkdir /content \
    && echo "library(box)" > /content/script.R \
    && echo "options(download.file.method = 'curl', download.file.extra = paste('-s -L -f -A ', shQuote(getOption('HTTPUserAgent'))))" > /content/.Rprofile

WORKDIR /content

ENV RENV_INSTALL_TEST_LOAD=True

RUN R -s -e "packrat::init(enter = FALSE, infer.dependencies = FALSE)"
# install by R of box into the packrat library..
RUN R -s -e "install.packages('box')"
RUN R -s -e "packrat::snapshot()"
RUN rm -rf packrat/lib* packrat/src
# installation by packrat of box into the packrat library.
RUN R -s -e "packrat::restore()"
RUN R -s -f "script.R"
$ docker build --progress=plain --no-cache-filter=setup -f Dockerfile.packrat-box .
#14 [installation 6/8] RUN rm -rf packrat/lib* packrat/src
#14 DONE 0.3s

#15 [installation 7/8] RUN R -s -e "packrat::restore()"
#15 0.871 Installing box (1.1.3) ...
#15 3.759   OK (downloaded binary)
#15 3.759 Installing packrat (0.9.1-1) ...
#15 9.703   OK (built source)
#15 DONE 9.8s
toph-allen commented 1 year ago

I have no idea why lintr is exiting with error code 31. https://github.com/rstudio/packrat/actions/runs/5814162592/job/15763932085?pr=718#step:5:80

toph-allen commented 1 year ago

Ok so it's just Lintr's error code for erring when it encounters warnings.

https://github.com/r-lib/lintr/blob/f8bb91e7f0fd749f9a28523006a4cedd369c2688/R/methods.R#L106C9-L108

So I guess my question is, why are we getting so many indentation warnings where we had none before? Investigating…

Turns out indentation_linter is a new default, and so we just need to exclude it.