Skip to content

Add v3 r and rstudio images with R 4.5.3 and updated packages#195

Open
remlapmot wants to merge 18 commits into
opensafely-core:mainfrom
remlapmot:create-v3
Open

Add v3 r and rstudio images with R 4.5.3 and updated packages#195
remlapmot wants to merge 18 commits into
opensafely-core:mainfrom
remlapmot:create-v3

Conversation

@remlapmot
Copy link
Copy Markdown
Contributor

@remlapmot remlapmot commented Mar 18, 2026

Paging @bloodearnest

R 4.5.3, which according to the R-Core team will be the last patch release of R 4.5 https://stat.ethz.ch/pipermail/r-announce/2026/000718.html, was released last week on the 11th March. So I'd say it makes sense to have v3 r and rstudio images including that - which is what this does (and the v2 image is about 1 year old now - which is my personal limit for R related stuff).

The v3 additions are essentially a copy of what we do for v2 with the updated R and updated CRAN_DATE:

  • The updated CRAN_DATE gets us the current versions of the packages notably including ggplot2 version 4.
  • In a few places I've had to generalise the code to swap a hardcoded v2 for using the MAJOR_VERSION env var.
  • Comparing the number of R packages - v2 has 544 - v3 has 545 (mainly due to different dependency requirements). I think the only notable difference is that on the new v3 CRAN_DATE the parglm R package is no longer available on CRAN https://cran.r-project.org/package=parglm, and the parglm GitHub repo has been untouched for 5 years https://github.com/boennecd/parglm, so in v3 I have replaced parglm with the fastglm package https://cran.r-project.org/package=fastglm.
  • And I realised we never switched from the netlib BLAS/LAPACK to the faster OpenBLAS and its LAPACK - I've made that switch in v3 - running sessionInfo() this is reported in the following lines
    ❯ docker run -it --rm --platform linux/amd64 r:v3
    
    R version 4.5.3 (2026-03-11) -- "Reassured Reassurer"
    Copyright (C) 2026 The R Foundation for Statistical Computing
    Platform: x86_64-pc-linux-gnu
    
    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under certain conditions.
    Type 'license()' or 'licence()' for distribution details.
    
    R is a collaborative project with many contributors.
    Type 'contributors()' for more information and
    'citation()' on how to cite R or R packages in publications.
    
    Type 'demo()' for some demos, 'help()' for on-line help, or
    'help.start()' for an HTML browser interface to help.
    Type 'q()' to quit R.
    
    > sessionInfo()
    R version 4.5.3 (2026-03-11)
    Platform: x86_64-pc-linux-gnu
    Running under: Ubuntu 22.04.5 LTS
    
    Matrix products: default
    BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
    LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0
    
  • I also bumped the version of rstudio-server in v2.

As usual there was a nice summary of what's new in R 4.5 by Jumping Rivers https://www.jumpingrivers.com/blog/whats-new-r45/.

I don't believe I touched anything to do with v1 - so its epic 2hr build should still run. I have run the v2 and v3 r and rstudio builds and tests locally.

Maybe the opensafely CLI would need checking to see if it allows r:v3 and rstudio:v3?

Also - remember I have no permissions - so I can't formally 'request review' - and you'll have to trigger CI builds etc.

Add v3 dependencies for httpgd via unigd
Remove parglm from v3 as no longer on CRAN. parglm was archived on CRAN on 2026-01-29. I believe that fastglm is its closest replacement on CRAN on the v3 CRAN_DATE.
Only run `just check` for v2 and v3 since packages.toml does not exist for v1

Allow for v3 in else condition

Protect against v#/pkg.lock file not existing on first run
And pass version to `just check` in CI
Use MAJOR_VERSION instead of hardcoded v2

Create .local_pkg_dir object as a hidden object - as its name begins with a dot.

Convert local-packages-README.md to Rmd to pass version

Delete typo

Amends for v3 when writing package list
Add MAJOR_VERSION ENV for rprofile-site-append-2.R

Ensure MAJOR_VERSION is available to R and rstudio-server
Amend hardcoded v2 to use MAJOR_VERSION environment variable

In tests/test-loading-packages.R issue a more informative message (which
will likely reveal which runtime system dependency package is missing)
if a package fails to load
Since OpenBLAS (which includes its own LAPACK) is typically 4–6× faster
for linear algebra operations than the reference netlib BLAS/LAPACK that
Debian ships by default.
@rebkwok
Copy link
Copy Markdown
Contributor

rebkwok commented Apr 15, 2026

@remlapmot Many thanks for this. Everything looks good, and I've triggered the CI runs on the branch. I want to double-check the replacement of parglm with fastglm with the research team just so they're aware, and we'll have a wider discussion with the tech team about docs etc and the process for releasing a v3.

@remlapmot
Copy link
Copy Markdown
Contributor Author

remlapmot commented Apr 16, 2026

Thanks Becky

As far as I know fastglm is the best replacement for parglm in terms of features (i.e., they both fit Generalised Linear Models like the core stats library glm() function does - they just do so much faster). The only drawback is that unfortunately fastglm uses a slightly different syntax to parglm. I believe that parglm uses exactly the same syntax as the stats::glm() function, so if people had parglm::parglm(...) calls in their code they could simply amend those to stats::glm(...) and they would work - just with a longer runtime - or they could make the small syntax change within the call and use fastglm::fastglm(...slightly different syntax here...) to retain the faster runtime.

After releasing r:v3 and rstudio:v3 the only amend I would recommend you make in the opensafely CLI is changing the default version of rstudio to v3 in the opensafely launch command (such that

opensafely launch rstudio

will invoke opensafely launch rstudio:v3 instead of opensafely launch rstudio:v2 as it currently does). I think that would just be a one character amend on this line within the launch_rstudio() function.

https://github.com/opensafely-core/opensafely-cli/blob/e63d4c4b759c639810eee7cf81d9ff71b00f8e24/opensafely/launch.py#L165

I have checked that when the ghcr.io/opensafely-core/r:v3 and ghcr.io/opensafely-core/rstudio:v3 images exist the following two CLI calls already work as expected

opensafely exec r:v3
opensafely launch rstudio:v3

You can test this locally by building the two images from this branch then retagging e.g.,

just build v3
just build-rstudio v3
docker tag r:v3 ghcr.io/opensafely-core/r:v3
docker tag rstudio:v3 ghcr.io/opensafely-core/rstudio:v3

then running those commands.

@remlapmot
Copy link
Copy Markdown
Contributor Author

Hi Becky

PR updated.

Good news. I have actually taken over maintainership of the parglm package myself and yesterday I got it reinstated on CRAN, so I have added included it the v3 image.

Also,

  • I have kept the fastglm package in v3 because Will is interested in using it.
  • I have also added SEQTaRget package to the v3 image as it our package for sequential target trial estimation and it is an alternative to the TrialEmulation package (which is already in v2 and v3).

@rebkwok
Copy link
Copy Markdown
Contributor

rebkwok commented Apr 22, 2026

Awesome, thanks @remlapmot

@remlapmot remlapmot force-pushed the create-v3 branch 2 times, most recently from 5819c08 to e409b80 Compare April 27, 2026 05:59
remlapmot added 2 commits May 13, 2026 08:57
To after when parglm was reinstated on CRAN. And when fastglm had been bumped to 0.1.0 and parglm to 0.1.9.
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.

3 participants