I've deployed a Shiny app on shinyapps.io that executes code that is inserted within the app. For example, if you insert the following code within the app:
1 + 2
The Shiny app returns:
3
This works fine as long as all the packages used in the inserted code have been specified already during the deployment process of the app.
However, if an unknown package is used within the inserted code, the Shiny app doesn't work anymore. For example, the following input returns an error message:
install.packages("Hmisc")
1 + 2
Output:
'lib = ".../lib/R/library"' is not writable
Warning in install.packages("Hmisc") :
Warning: Error in install.packages: unable to install packages
This could be solved by specifying all required packages (i.e. "Hmisc") during the deployment of the app. However, since I don't know all the required packages before the deployment of the app, I need to find a way to install and load packages AFTER the deployment. How could I do that?
.libPaths(c(tempdir(), .libPaths()))(I currently can't test it)..libPaths(c(tempdir(), .libPaths()))andinstall.packages("Hmisc", repos = "https://cloud.r-project.org"). Could you elaborate on the security risk in some more detail? I'm afraid I still don't understand why this might be a problem for my app (I don't have much experience with this). Thanks again!Sys.sleep(1e6), then the app could stop working until the sleep finishes. this can affect every user connected if the app runs in a single thread.