I'm deploying a Shiny App on a shiny server maintained by my university, and there are many .libPaths() that contain different versions of packages.
> .libPaths()
[1] "/zeolite/rpauloo/R/x86_64-pc-linux-gnu-library/3.4"
[2] "/nfs/admin/software/xenial/system-gcc/R_libs"
[3] "/usr/local/lib/R/site-library"
[4] "/usr/lib/R/site-library"
[5] "/usr/lib/R/library"
When my shiny app boots up, shiny is loaded by default from .libPaths()[2] , which then imports R6 V.2.2.1 , also from this path.
However, my code depends on R6 >= V.2.2.2 , which I have in .libPaths()[1].
It would be simple enough to have my SysAdmin update R6 in .libPaths()[2] , but they cannot because other people's apps depend on the libraries on that path, and we don't want to break those.
I've tried:
- detaching
R6 and loading it from .libPaths()[1]
detach("package:R6", unload=TRUE, force = TRUE, character.only = TRUE)
library(R6, lib.loc = "/zeolite/rpauloo/R/x86_64-pc-linux-gnu-library/3.4")
- detaching
shiny and loading it from .libPaths()[1]
detach("package:shiny", unload=TRUE, force = TRUE, character.only = TRUE)
library(shiny, lib.loc = "/zeolite/rpauloo/R/x86_64-pc-linux-gnu-library/3.4")
- setting my
.libPaths() from the start in the global.R file to only include the path I want.
.libPaths(.libPaths()[1])
- adding an
etc folder under "/zeolite/rpauloo/R" that contains the following Rprofile.site file (advice from here):
.First <- function(){
.libPaths("/zeolite/rpauloo/R/x86_64-pc-linux-gnu-library/3.4")
}
None of these approaches work. Why?
-
R6 is an attached package, so it can't be unloaded.
- not sure why unloading/reloading shiny doesn't work
- Shiny Server loads
shiny from .libPaths()[2] to begin with, before the global.R file is sourced, so setting libPaths() doesn't help.
- the
Rprofile.site file is probably in the wrong directory, but putting it in an admin directory will mess with other apps
Question
How can I configure my shiny app to load shiny from a specific .libPath on startup?
Or have I mis-conceptualized the problem? Is there another way to go about this?