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.4.0 (2024-04-24)
#>  os       Linux Mint 21.3
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_CA:en
#>  collate  en_CA.UTF-8
#>  ctype    en_CA.UTF-8
#>  tz       America/Montreal
#>  date     2024-05-03
#>  pandoc   2.9.2.1 @ /usr/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
#>  ! package     * version date (UTC) lib source
#>  P cachem        1.0.8   2023-05-01 [?] RSPM
#>  P cli           3.6.2   2023-12-11 [?] RSPM
#>  P devtools      2.4.5   2022-10-11 [?] RSPM (R 4.4.0)
#>  P digest        0.6.35  2024-03-11 [?] RSPM
#>  P ellipsis      0.3.2   2021-04-29 [?] RSPM
#>  P evaluate      0.23    2023-11-01 [?] RSPM
#>  P fastmap       1.1.1   2023-02-24 [?] RSPM
#>  P fs            1.6.4   2024-04-25 [?] CRAN (R 4.4.0)
#>  P glue          1.7.0   2024-01-09 [?] RSPM
#>  P htmltools     0.5.8.1 2024-04-04 [?] RSPM
#>  P htmlwidgets   1.6.4   2023-12-06 [?] RSPM
#>  P httpuv        1.6.15  2024-03-26 [?] RSPM
#>  P jsonlite      1.8.8   2023-12-04 [?] RSPM
#>  P knitr         1.46    2024-04-06 [?] RSPM
#>  P later         1.3.2   2023-12-06 [?] RSPM
#>  P lifecycle     1.0.4   2023-11-07 [?] RSPM
#>  P magrittr      2.0.3   2022-03-30 [?] RSPM
#>  P memoise       2.0.1   2021-11-26 [?] RSPM
#>  P mime          0.12    2021-09-28 [?] RSPM
#>  P miniUI        0.1.1.1 2018-05-18 [?] RSPM (R 4.4.0)
#>  P pkgbuild      1.4.4   2024-03-17 [?] RSPM (R 4.4.0)
#>  P pkgload       1.3.4   2024-01-16 [?] RSPM (R 4.4.0)
#>  P processx      3.8.4   2024-03-16 [?] RSPM
#>  P profvis       0.3.8   2023-05-02 [?] RSPM (R 4.4.0)
#>  P promises      1.3.0   2024-04-05 [?] RSPM
#>  P ps            1.7.6   2024-01-18 [?] RSPM
#>  P purrr         1.0.2   2023-08-10 [?] RSPM
#>  P quarto      * 1.4     2024-03-06 [?] RSPM
#>  P R.cache       0.16.0  2022-07-21 [?] RSPM
#>  P R.methodsS3   1.8.2   2022-06-13 [?] RSPM
#>  P R.oo          1.26.0  2024-01-24 [?] RSPM
#>  P R.utils       2.12.3  2023-11-18 [?] RSPM
#>  P R6            2.5.1   2021-08-19 [?] RSPM
#>  P Rcpp          1.0.12  2024-01-09 [?] RSPM
#>  P remotes       2.5.0   2024-03-17 [?] RSPM (R 4.4.0)
#>  P renv          1.0.7   2024-04-11 [?] RSPM (R 4.4.0)
#>  P rlang         1.1.3   2024-01-10 [?] RSPM
#>  P rmarkdown     2.26    2024-03-05 [?] RSPM
#>  P rstudioapi    0.16.0  2024-03-24 [?] RSPM
#>  P sessioninfo   1.2.2   2021-12-06 [?] RSPM (R 4.4.0)
#>  P shiny         1.8.1.1 2024-04-02 [?] RSPM (R 4.4.0)
#>  P stringi       1.8.3   2023-12-11 [?] RSPM
#>  P stringr       1.5.1   2023-11-14 [?] RSPM
#>  P styler      * 1.10.3  2024-04-07 [?] RSPM
#>  P urlchecker    1.0.1   2021-11-30 [?] RSPM (R 4.4.0)
#>  P usethis       2.2.3   2024-02-19 [?] RSPM (R 4.4.0)
#>  P vctrs         0.6.5   2023-12-01 [?] RSPM
#>  P xfun          0.43    2024-03-25 [?] RSPM
#>  P xtable        1.8-4   2019-04-21 [?] RSPM (R 4.4.0)
#>  P yaml          2.3.8   2023-12-11 [?] RSPM
#> 
#>  [1] /tmp/Rtmpqewoqy/renv-use-libpath-25ac427b476523
#>  [2] /tmp/Rtmpqewoqy/renv-sandbox
#> 
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────