Skip to content

Dockerfile: use pinned R dependencies#21

Merged
davidfrantz merged 5 commits into
davidfrantz:mainfrom
pjonsson:pin-r-dependencies
May 28, 2026
Merged

Dockerfile: use pinned R dependencies#21
davidfrantz merged 5 commits into
davidfrantz:mainfrom
pjonsson:pin-r-dependencies

Conversation

@pjonsson
Copy link
Copy Markdown
Contributor

@pjonsson pjonsson commented Apr 9, 2026

Install renv and use that to restore
the package versions from the lockfile.

@pjonsson
Copy link
Copy Markdown
Contributor Author

pjonsson commented Apr 9, 2026

I don't know anything about R, but running R -e 'lapply(.libPaths(), list.files)' shows a bunch of packages, including the ones that were previously installed through install.packages().

I have only run things inside a Docker container, so that is what I would recommend to do to update renv.lock as well. Updating is done through running renv::update() according to the documentation. Installing new packages can be done in the usual way through install.packages() followed by renv::snapshot() to get the new packages recorded in the lockfile.

I haven't tested that the installed R packages actually work since I'm not sure how to do that, so you should probably try that before merging this.

@pjonsson
Copy link
Copy Markdown
Contributor Author

The pinning seems to work as intended, fs 2.1.0 was released a couple of days ago and that broke the build of the main branch (#22 fixes it), but the image on this branch still builds since it has pinned fs 2.0.1.

@pjonsson pjonsson force-pushed the pin-r-dependencies branch from 7a78fe7 to 533191a Compare April 24, 2026 13:19
@pjonsson pjonsson force-pushed the pin-r-dependencies branch from 533191a to d0b0386 Compare May 16, 2026 13:27
@pjonsson
Copy link
Copy Markdown
Contributor Author

This apparently had conflicts after the comment changes which I missed. I've rebased it now, sorry about that.

Install renv and use that to restore
the package versions from the lockfile.
@pjonsson pjonsson force-pushed the pin-r-dependencies branch from d0b0386 to bd217ff Compare May 22, 2026 14:00
@pjonsson
Copy link
Copy Markdown
Contributor Author

Updated renv.lock to the latest versions, and amended the the instructions for how to do it with the renv::snapshot() that needs to be done after renv::update() to get the new packages written to the lock file.

Comment thread Dockerfile Outdated
echo -n "CCACHE=ccache\nCC=\$(CCACHE) gcc\nCXX=\$(CCACHE) g++\nCXX11=\$(CCACHE) g++\nCXX14=\$(CCACHE) g++\nCXX17=\$(CCACHE) g++\nFC=\$(CCACHE) gfortran\nF77=\$(CCACHE) gfortran\n" > $HOME/.R/Makevars && \
echo -n "max_size = 200M\nsloppiness = include_file_ctime\nhash_dir = false\n" > $HOME/.config/ccache/ccache.conf && \
R -s -e 'renv::restore()' && \
R -s -e 'options(Ncpus = parallel::detectCores()); renv::restore()' && \
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that is lovely, thank you!

@davidfrantz
Copy link
Copy Markdown
Owner

I think this is now good to go, thanks Peter.

The only thing I noticed is that R itself is not really pinned down.

renv.lock assumes "Version": "4.3.3",, but the apt-get installer might install a different version in the future.

@pjonsson
Copy link
Copy Markdown
Contributor Author

The only thing I noticed is that R itself is not really pinned down.

renv.lock assumes "Version": "4.3.3",, but the apt-get installer might install a different version in the future.

Yes, we're way outside my wheelhouse with this since I have never used R, but since the image is using the Ubuntu packages the R version will change when the Ubuntu release is upgraded. The cadence for that is a new Ubuntu LTS release every 2 years, so if you merge this PR I'll rebase the GDAL 3.13 PR and amend it with an update to renv.lock since GDAL 3.13 is based on Ubuntu 26.04, and then you can forget about it until spring of 2028.

(The GDAL 3.13 PR also uses numpy 2.x, so it needs some kind of additional change with the numpy interfacing in the C code in the FORCE repository, but I think the PR in this repository does what it claims.)

@davidfrantz davidfrantz merged commit 70f75ed into davidfrantz:main May 28, 2026
@pjonsson pjonsson deleted the pin-r-dependencies branch May 28, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants