The pinned R dependencies are managed via renv.
renv.lock records the exact version of every package (direct and transitive).
To update it, spin up an ephemeral container from the same base image used by the
Dockerfile, mount this repository into it, and run the renv commands there.
The only file that needs to be committed afterwards is the updated renv.lock.
Run this once from the root of the repository (re-run whenever the base image
SHA in the FROM line of the Dockerfile changes):
docker build -t gdal-r-update - <<'EOF'
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.11.3
RUN DEBIAN_FRONTEND=noninteractive apt-get update -qq && \
apt-get install -y --no-install-recommends \
build-essential \
curl \
r-base \
r-cran-renv \
gfortran \
libblas-dev \
liblapack-dev \
libuv1-dev \
pandoc \
zlib1g-dev
EOFThis installs R and all build dependencies as root inside a throwaway image.
docker run --rm -it \
-v "$(pwd)":/work \
-u "$(id -u):$(id -g)" \
-e HOME=/tmp \
gdal-r-update \
bashRunning as your own UID/GID (-u) ensures that any files written to the
mounted repository — including the updated renv.lock — are owned by you.
-e HOME=/tmp gives renv a writable home directory inside the container.
cd /work
export RENV_PATHS_LIBRARY=/tmp/renv-lib # keep packages out of the mounted volume
Rscript -e 'renv::restore()'This installs all packages at the versions currently recorded in renv.lock.
It is required before updating so that renv knows what is installed.
Use Rscript -e 'options(Ncpus = parallel::detectCores()); renv::restore() to get some speedup by building the individual packages in parallel.
Update all packages to the latest CRAN versions:
Rscript -e 'renv::update()'Update a single package:
Rscript -e 'renv::update("echarts4r")'Install a new package and add it to the lockfile:
Rscript -e 'install.packages("newpkg")'Rscript -e 'renv::snapshot()'This overwrites renv.lock with the currently installed versions.
Because /work is a bind mount, the file is updated directly on your host.
git add renv.lock
git commit -m "renv: update R package dependencies"- The directly required packages are:
rmarkdown,echarts4r,snow,snowfall,getopt. All other entries inrenv.lockare their transitive dependencies. snapshot.typeis set to"all"inrenv/settings.json, so every installed package (including indirect dependencies) is captured in the lockfile.renv/library/is listed inrenv/.gitignoreand must not be committed.- The
R.Versionfield inrenv.lockreflects the R version inside the container. Make sure the base image SHA in thedocker runcommand matches the one in theFROMline of the Dockerfile to keep R versions consistent.