Uptating Ubuntu packages crashed my renv R project

R
R tips
Author

Philippe Massicotte

Published

August 16, 2022

I am using renv quite a lot. Recently, I had to return to an older project that was using this package to manage package dependencies. When I tried to load tidyverse, I got the following message:

> library(tidyverse)
Error: package or namespace load failed for ‘tidyverse’ in dyn.load(file, DLLpath = DLLpath, ...):
  unable to load shared object '/home/xxx/.local/share/renv/cache/v5/R-4.2/x86_64-pc-linux-gnu/stringi/1.7.6/bba431031d30789535745a9627ac9271/stringi/libs/stringi.so':
  libicui18n.so.66: cannot open shared object file: No such file or directory

This means that stringi v1.7.6 (a dependency for the tidyverse) was originally compiled with a certain version of libicui18n, and that after a system update/upgrade on my Ubuntu computer, this file no longer exists. One solution to fix this is to rebuild the stringi package using the new version of libicui18n installed on your computer. To do so, you can use renv::install(package_name@version) to specify a specific version of an R package to be installed/compiled.

renv::install(
  "stringi@1.7.6",
  rebuild = TRUE,
  repos = "https://cran.rstudio.com/"
)

stringi@1.7.6 means to install version 1.7.6 of the package, the same version that was included in the renv.lock file. After this operation, you should be able to do library(tidyverse) without problems.

If for whatever reason you have to change to a specific version of an R package, you can use renv::record() to modify the renv.lock file:

renv::record("stringi@1.7.8")
Session info
#> ─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.1 (2022-06-23)
#>  os       Ubuntu 22.04.1 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_CA:en
#>  collate  en_CA.UTF-8
#>  ctype    en_CA.UTF-8
#>  tz       America/Toronto
#>  date     2022-08-20
#>  pandoc   NA (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
#>  ! package     * version date (UTC) lib source
#>  P cachem        1.0.6   2021-08-19 [?] RSPM (R 4.2.0)
#>  P callr         3.7.1   2022-07-13 [?] RSPM (R 4.2.0)
#>  P cli           3.3.0   2022-04-25 [?] RSPM (R 4.2.0)
#>  P crayon        1.5.1   2022-03-26 [?] RSPM (R 4.2.0)
#>  P devtools      2.4.4   2022-07-20 [?] RSPM (R 4.2.0)
#>  P digest        0.6.29  2021-12-01 [?] RSPM (R 4.2.0)
#>  P ellipsis      0.3.2   2021-04-29 [?] RSPM (R 4.2.0)
#>  P evaluate      0.16    2022-08-09 [?] RSPM (R 4.2.0)
#>  P fastmap       1.1.0   2021-01-25 [?] RSPM (R 4.2.0)
#>  P fs            1.5.2   2021-12-08 [?] RSPM (R 4.2.0)
#>  P glue          1.6.2   2022-02-24 [?] RSPM (R 4.2.0)
#>  P htmltools     0.5.3   2022-07-18 [?] RSPM (R 4.2.0)
#>  P htmlwidgets   1.5.4   2021-09-08 [?] RSPM (R 4.2.0)
#>  P httpuv        1.6.5   2022-01-05 [?] RSPM (R 4.2.0)
#>  P jsonlite      1.8.0   2022-02-22 [?] RSPM (R 4.2.0)
#>  P knitr         1.39    2022-04-26 [?] RSPM (R 4.2.0)
#>  P later         1.3.0   2021-08-18 [?] RSPM (R 4.2.0)
#>  P lifecycle     1.0.1   2021-09-24 [?] RSPM (R 4.2.0)
#>  P magrittr      2.0.3   2022-03-30 [?] RSPM (R 4.2.0)
#>  P memoise       2.0.1   2021-11-26 [?] RSPM (R 4.2.0)
#>  P mime          0.12    2021-09-28 [?] RSPM (R 4.2.0)
#>  P miniUI        0.1.1.1 2018-05-18 [?] RSPM (R 4.2.0)
#>  P pkgbuild      1.3.1   2021-12-20 [?] RSPM (R 4.2.0)
#>  P pkgload       1.3.0   2022-06-27 [?] RSPM (R 4.2.0)
#>  P prettyunits   1.1.1   2020-01-24 [?] RSPM (R 4.2.0)
#>  P processx      3.7.0   2022-07-07 [?] RSPM (R 4.2.0)
#>  P profvis       0.3.7   2020-11-02 [?] RSPM (R 4.2.0)
#>  P promises      1.2.0.1 2021-02-11 [?] RSPM (R 4.2.0)
#>  P ps            1.7.1   2022-06-18 [?] RSPM (R 4.2.0)
#>  P purrr         0.3.4   2020-04-17 [?] RSPM (R 4.2.0)
#>  P R6            2.5.1   2021-08-19 [?] RSPM (R 4.2.0)
#>  P Rcpp          1.0.9   2022-07-08 [?] RSPM (R 4.2.0)
#>  P remotes       2.4.2   2021-11-30 [?] RSPM (R 4.2.0)
#>    renv          0.15.5  2022-05-26 [1] RSPM (R 4.2.0)
#>  P rlang         1.0.4   2022-07-12 [?] RSPM (R 4.2.0)
#>  P rmarkdown     2.14    2022-04-25 [?] RSPM (R 4.2.0)
#>  P sessioninfo   1.2.2   2021-12-06 [?] RSPM (R 4.2.0)
#>  P shiny         1.7.2   2022-07-19 [?] RSPM (R 4.2.0)
#>  P stringi       1.7.8   2022-07-11 [?] RSPM (R 4.2.0)
#>  P stringr       1.4.0   2019-02-10 [?] RSPM (R 4.2.0)
#>  P urlchecker    1.0.1   2021-11-30 [?] RSPM (R 4.2.0)
#>  P usethis       2.1.6   2022-05-25 [?] RSPM (R 4.2.0)
#>  P xfun          0.32    2022-08-10 [?] RSPM (R 4.2.0)
#>  P xtable        1.8-4   2019-04-21 [?] RSPM (R 4.2.0)
#>  P yaml          2.3.5   2022-02-21 [?] RSPM (R 4.2.0)
#> 
#>  [1] /media/work/r-blog/renv/library/R-4.2/x86_64-pc-linux-gnu
#>  [2] /usr/local/lib/R/library
#> 
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────