opensafely-core / research-template-docker

This provides the devcontainer Docker image used by repos created from the OpenSAFELY research template.
Other
0 stars 0 forks source link

Error when attempting to load the `tidyverse` package #31

Closed iaindillingham closed 1 month ago

iaindillingham commented 1 month ago

@alschaffer reports the following error when attempting to load the tidyverse package in RStudio:

> library("tidyverse")
Error: package or namespace load failed for ‘tidyverse’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/usr/local/lib/R/site-library/xml2/libs/xml2.so':
  libxml2.so.2: cannot open shared object file: No such file or directory
In addition: Warning messages:
1: replacing previous import ‘ellipsis::check_dots_unnamed’ by ‘rlang::check_dots_unnamed’ when loading ‘tibble’ 
2: replacing previous import ‘ellipsis::check_dots_used’ by ‘rlang::check_dots_used’ when loading ‘tibble’ 
3: replacing previous import ‘ellipsis::check_dots_empty’ by ‘rlang::check_dots_empty’ when loading ‘tibble’ 
4: replacing previous import ‘ellipsis::check_dots_unnamed’ by ‘rlang::check_dots_unnamed’ when loading ‘pillar’ 
5: replacing previous import ‘ellipsis::check_dots_used’ by ‘rlang::check_dots_used’ when loading ‘pillar’ 
6: replacing previous import ‘ellipsis::check_dots_empty’ by ‘rlang::check_dots_empty’ when loading ‘pillar’ 

Andrea started a Codespace from opensafely/waiting-list. I was able to recreate the above error in a new Codespace started from opensafely/research-template.^1 I successfully loaded several other packages from packages.csv.

StevenMaude commented 1 month ago

In the OpenSAFELY R image, libxml2 is installed as a system package. Testing inside that R image, if you apt remove libxml2, you get a similar error inside that R image:

> library(tidyverse)
Error: package or namespace load failed for ‘tidyverse’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/renv/lib/R-4.0/x86_64-pc-linux-gnu/xml2/libs/xml2.so':
  libxml2.so.2: cannot open shared object file: No such file or directory
StevenMaude commented 1 month ago

Additional dependencies for the R Docker image in:

https://github.com/opensafely-core/r-docker/blob/bb8e0325c84f7b606124bf7294d5e4a5fda2681c/build-dependencies.txt https://github.com/opensafely-core/r-docker/blob/bb8e0325c84f7b606124bf7294d5e4a5fda2681c/dependencies.txt

(Not directly relevant, but the Python image has additionally installed dependencies too.)

Jongmassey commented 1 month ago

I'm not sure we need the build dependencies as we're not building any of these packages from source. The omission of the dependencies is definitely an error.

I suppose if we want to support user installation of R packages from source then we might need those build dependencies. However, there may be additional dependencies for packages we don't know about.

Jongmassey commented 1 month ago

Importing all packages:

ip = unique(as.list(as.data.frame(installed.packages()[,c(1)])))
for (i in ip[[1]]){
  eval(parse(text=paste("library(\"",i,"\")",sep="")))
}

shows other missing dependencies:

Which are in dependencies.txt or build-dependencies.txt (*). libtcl and libtk (**) are odd ones, not in either dependencies file, but feature in 20.04-library-changes.txt

Jongmassey commented 1 month ago

AFAICT assessing only direct dependencies: brms isn't used magick is odbc is, but only for the high cost drugs dataset rgdal isn't used sf is used tcltk isn't used

Maybe in addition to libxml2 we should also install libmagick++ and libudunits to support existing researcher code?