UCSF-CBI / rstudio-server-controller

RStudio Server Controller (RSC) - A Tool for Launching a Personal Instance of the RStudio Server
https://github.com/UCSF-CBI/rstudio-server-controller
ISC License
4 stars 2 forks source link

ROBUSTNESS: Detect when there's an RStudio session to be loaded that is of a different version that R --version #75

Open HenrikBengtsson opened 1 year ago

HenrikBengtsson commented 1 year ago

Background

A user on C4 reported that they could not install R packages from their personal RStudio Server instance. They got errors such as:

Warning messages:
1: In system2(cmd0, args, env = env, stdout = outfile, stderr = outfile,  :
  error in running command
2: In install.packages(...) :
  installation of package 'R.methodsS3' had non-zero exit status

They later reported that their R package library path was:

> .libPaths()
[1] "/c4/home/alice/R/x86_64-pc-linux-gnu-library/4.2-CBI-gcc10"
[2] "/software/c4/cbi/software/R-4.2.1-gcc10/lib64/R/library"     
[3] "/software/c4/cbi/software/R-4.2.2-gcc10/lib64/R/library"  

Note that there are two "system" library paths, one for R 4.2.1 and one for R 4.2.2.

They used module load CBI rstudio-server-controller, which depends on the r module, which in turn loads the most recent R version. In contrast to the RStudio Server, running R in the terminal would report on a normal library path:

> .libPaths()
[1] "/c4/home/alice/R/x86_64-pc-linux-gnu-library/4.2-CBI-gcc10"
[2] "/software/c4/cbi/software/R-4.2.2-gcc10/lib64/R/library"  

Troubleshooting

Looking back at the RStudio Console output, we found:

R version change [4.2.1 -> 4.2.2] detected when restoring session; search path not restored

This suggests that the RStudio session was launched on R 4.2.1 and then saved. But since then, the default R module load CBI r has been updated to R 4.2.2. When the user launched RStudio this time, the above message was generated, and then we got that mix-and-match .libPaths().

Resolution

Restarting the R session in RStudio by selecting 'Session' -> 'Restart R (Ctrl+Shift+F10)'. This restarted R (= R 4.2.2) and after that we got:

> .libPaths()
[1] "/c4/home/alice/R/x86_64-pc-linux-gnu-library/4.2-CBI-gcc10"
[2] "/software/c4/cbi/software/R-4.2.2-gcc10/lib64/R/library"  

and install.packages() works again.

Suggestion

Have rsc detect when this can happen and produce an informative error instead of launch the RStudio Server. Maybe it's possible to automatically resolve it. Maybe ask RStudio to update the message to say that R should be restarted;

R version change [4.2.1 -> 4.2.2] detected when restoring session; search path not restored.
Because of this, there is a risk that R will not work properly.  To resolve this, please restart R
under the RStudio menu 'Session'.

Alternatively, if possible, launch the RStudio Server, but inject a big message saying that 'Session' -> 'Restart R (Ctrl+Shift+F10)' is required.

HenrikBengtsson commented 1 year ago

This should be high priority, because there's a high risk it will happen each time we upgrade R.