Installed & loaded survminer as follows:
install.packages('survminer')
library(survminer)
This gives the following error:
Loading required package: ggpubr
Error: package or namespace load failed for ‘ggpubr’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
namespace ‘cli’ 3.2.0 is already loaded, but >= 3.4.0 is required
Error: package ‘ggpubr’ could not be loaded
During survminer install, cli version 3.6.1 was automatically installed. Since the above error says cli version >= 3.4.0 is required, I tried loading cli with library(cli). This gives the following error:
Package ‘cli’ version 3.2.0 cannot be unloaded:
Error in unloadNamespace(package) : namespace ‘cli’ is imported by ‘pillar’ so cannot be unloaded
And so on. Pillar imports cli so cli cannot be unloaded. Pillar itself cannot be unloaded because it is imported by tibble and dplyr. Tibble cannot be unloaded because it's imported by dplyr and ggplot2.
What I've tried:
I can unload dplyr and ggplot2, and then unload tibble (by unticking these in the Packages tab of RStudio). However, pillar then still acts as though these packages are loaded:
Warning message:
‘pillar’ namespace cannot be unloaded:
namespace ‘pillar’ is imported by ‘tibble’, ‘dplyr’ so cannot be unloaded
I've restarted R numerous times and am going round in circles reloading these package dependencies and others which sometimes come up (e.g. rlang package) in different orders because of the way they all seem to rely on each other.
Here is session info:
R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] rstudioapi_0.13 magrittr_2.0.2 tidyselect_1.2.0 munsell_0.5.0 colorspace_2.0-2
[6] R6_2.5.1 rlang_1.1.1 fansi_1.0.2 dplyr_1.1.2 tools_4.1.1
[11] grid_4.1.1 gtable_0.3.0 utf8_1.2.2 cli_3.2.0 withr_2.5.0
[16] tibble_3.2.1 lifecycle_1.0.3 ggsignif_0.6.4 vctrs_0.6.2 glue_1.6.1
[21] compiler_4.1.1 pillar_1.9.0 generics_0.1.2 scales_1.2.1 lubridate_1.8.0
[26] pkgconfig_2.0.3
Here are the packages auto-installed by survminer and their versions: packages auto-installed by survminer part 1 packages auto-installed by survminer part 2
The following packages are already installed when starting RStudio which is probably what's causing problems:
cli - v 3.2.0
commonmark - 1.7
dplyr - 1.0.8
ggplot2 - 3.3.5
lifecycle - 1.0.1
pillar - 1.7.0
purr - 0.3.4
rlang - 1.0.1
scales - 1.1.1
stringr -1.4.0
tibble - 3.1.6
tidyr - 1.2.0
tidyselect - 1.1.1
vctrs - 0.3.8
withr - 2.4.3
xfun - 0.29
Please note I cannot update R or change the pre-installed package versions as I am running RStudio on a cloud server. I also can't uninstall the pre-installed packages above with remove.packages:
Error in remove.packages : there is no package called ‘pillar’
Q: Is there a way to 'hard reset' all the packages installed/loaded in R so I can install more recent package versions without problems? Or is there a specific order in which I need to install/load/unload packages for survminer to work?
Thanks in advance!
You can take advantage of r2u which provides Ubuntu binaries for Ubuntu 20.04 (yours) and 22.04 (one newer). Many of us run this on servers, laptops, for CI, ...
To check, I just fired up container for 20.04 (while I run 22.10 here) and in the R 4.3.0 session asked for
install.packages("survminer"):and it calmly and quietly went off and downloaded and install 58 binary
aptpackages -- forsurvminerakar-cran-survminerand all its dependencies. This took well under a minute.(It then complained at startup that
ggpubrwas missing, so I addinstall.packages("ggpubr")which added 36 more.) Now all is well