Hello, I'm fairly new to administrating shiny-server and rstudio. We have an application that is trying to deploy and when it tries to initialize the application, it needs to install some packages for the user. However, when it tries to install, in this case, stringr, it fails with "error in contrib.url(repos,type)". I've seen the solution to this being to define the repository you need to install from. Since I'm not the developer, they tell me that we need to instead install the packages in a global location so that there are no installations necessary for the client. I downloaded and unzipped the packages.tar.gz files and placed them in /usr/share/R/library, which is a defined location in .libPaths(). But when I try to initialize the application, it still fails. My question is how and where would I install these packages to be globally referenced by the application so the user can just access the URL.
Have you make sure that the
run_as user (shiny by default) has propper permissions on that lib path, and that the
R_LIBS_SITE variable is correctly configured for that path?
You can try installing packages system wide from your system console with something like this
sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/', lib = '/usr/local/lib/R/site-library')\""
I hadn't thought of changing the permissions so that shiny owned that folder, I even added myself to the runas list, but my normal account doesn't own the folder either. Where can I set the R_LIBS_SITE variable?
Edit: I've changed the facl on the folder to allow shiny full privileges to the folder, but it still tries to install the package and fail.
Installing packages while the app is loading is not a good thing to do, and it is unnecessary because all your apps run as the same user, shiny, so manually installing system wide, your needed packages should be the right approach.
Also, you can change the
R_LIBS_SITE variable from your
.Renviron.site file, but if I was you, I would keep a standard lib path like
Seems I might be a bit lost on some file location. I have R under /usr/share/, which contains the library of packages I've installed, this is also a path for Rstudio. However, when I look under /etc, all I have is a shiny-server/ folder and no R. I'm working under the assumption that /usr/share is R's home path for the global environment since I don't want to install these packages in /usr/local for individual users. I don't have anything in /usr/local/lib like site-library.
If anyone happens to come upon this with questions. I had the wrong file location for installing packages. I was installing them in /usr/share/R/library, while the actual library path for shiny-server was /usr/lib64/R/library. Once the packages were installed there, we were good to go.