R Shiny Server installation package
Solution 1
The problem is that shiny-server cannot find the packages that you install, because it runs them as a different user called shiny
. This is the user is created upon installation of shiny-server
.
The easiest (and safest IMHO) way to solve this issue, is to install the required packages using this user account (shiny). This can be done using the following steps.
- Set a password for the
shiny
user account usingsudo passwd shiny
, now enter and confirm a password - Switch to the shiny account using:
su - shiny
- Call up
R
usingR
(without sudo) - Install the required packages, in this case:
install.packages("shiny")
Note that if you have rstudio-server installed on the same machine then you can perform steps 2-4 using that interface. Simply go the same domain/ip and use :8787 for the rstudio-server interface instead of :3838 for shiny-server.
Adapted from my answer here
Solution 2
I had similar issue. After reading the admin guide, here might be a solution for you.
You are having this error because whoever accessing the app does not have the shiny
package installed. If you do less /etc/shiny-server/shiny-server.conf
and you might notice the following on the first two lines:
# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;
In order to fix the issue, you may do either of the following:
- Switch to user
shiny
and install all packages there. e.g.,su shiny
. However, this is going to duplicate your installed libraries for all users. - A clean way is to always run
shiny
from another user with all the packages, by editingrun_as
in/etc/shiny-server/shiny-server.conf
. In this case, you may change the second line torun_as your_username shiny;
, so that it looks for your.libPaths()
and then shiny's.libPaths()
. You may also add multiple users here.
Smackboyg
Updated on June 04, 2022Comments
-
Smackboyg almost 2 years
Possible overlap:
Packages missing in shiny-server
R shiny / shiny-server - issue with finding packages
R - How to set the path of install.packages() for shiny server ? - UbuntuI have tried and read all of the above but still cannot get my Shiny Server to work at all.
I followed the installation instructions on http://www.rstudio.com/shiny/server/install-opensource, including the system-wide install of the shiny package:
$ sudo su - \ -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""
Shiny Server is installed properly and running,
~# sudo start shiny-server start: Job is already running: shiny-server
but when I browse to
domain:3838
I can see the welcome to shiny page, with errorError in eval(expr, envir, enclos) : The Shiny package was not found in the library. Ensure that Shiny is installed and is available in the Library of the user you're running this application as. Calls: local -> eval.parent -> eval -> eval -> eval -> eval Execution halted
Opening R,
install.packages('shiny', repos='http://cran.rstudio.com/')
, and thenlibrary(shiny)
or any other package, tells me it cannot be found.I am really quite stuck, not only can I not install/load any packages, I can't seem to find where they are going.
EDIT:
install.packages(c("geonames"))
Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified)> library()
Warning message:
In library() :
libraries ‘/usr/local/lib/R/site-library’, ‘/usr/lib/R/site-library’ contain n o packagesAND
> installed.packages()[,1:2] Package LibPath base "base" "/usr/lib/R/library" boot "boot" "/usr/lib/R/library" class "class" "/usr/lib/R/library" cluster "cluster" "/usr/lib/R/library" codetools "codetools" "/usr/lib/R/library" compiler "compiler" "/usr/lib/R/library" datasets "datasets" "/usr/lib/R/library" foreign "foreign" "/usr/lib/R/library" graphics "graphics" "/usr/lib/R/library" grDevices "grDevices" "/usr/lib/R/library" grid "grid" "/usr/lib/R/library" KernSmooth "KernSmooth" "/usr/lib/R/library" lattice "lattice" "/usr/lib/R/library" MASS "MASS" "/usr/lib/R/library" Matrix "Matrix" "/usr/lib/R/library" methods "methods" "/usr/lib/R/library" mgcv "mgcv" "/usr/lib/R/library" nlme "nlme" "/usr/lib/R/library" nnet "nnet" "/usr/lib/R/library" parallel "parallel" "/usr/lib/R/library" rpart "rpart" "/usr/lib/R/library" spatial "spatial" "/usr/lib/R/library" splines "splines" "/usr/lib/R/library" stats "stats" "/usr/lib/R/library" stats4 "stats4" "/usr/lib/R/library" survival "survival" "/usr/lib/R/library" tcltk "tcltk" "/usr/lib/R/library" tools "tools" "/usr/lib/R/library" utils "utils" "/usr/lib/R/library"
Any help is greatly appreciated
SessionInfo:
> .libPaths() [1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library" [3] "/usr/lib/R/library"
> sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base
-
Smackboyg almost 10 yearsThanks for your answer. Unfortunately, it didn't help. I cannot seem to install/load any package.
install.packages('shiny', repos='http://cran.rstudio.com/') Installing package into ‘/usr/local/lib/R/site-library’
but browsing to /usr/local/lib/R/site-library tells me its empty. /usr/local/lib/R/site-library is in the .libPaths() -
Jan Stanstrup almost 10 yearsI cannot comment on the other "thread" so I put it here. To see permissions of the folders inside the "package folders" do:
ls -la "/usr/local/lib/R/site-library" "/usr/lib/R/site-library" "/usr/lib/R/library"
To see permissions for the folders themselves dols -la /usr/local/lib/R/" "/usr/lib/R/" "/usr/lib/R/"
-
Mxblsdl over 3 yearsI had to perform an additional step to get this to work. Navigate to
/etc/rstudio/rserver.conf
and add the lineauth-minimum-user-id=100
. This the min user id defaults to 1000 and myshiny
user was 996, which did not allow me to log in.