Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Shiny Server installation package

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 ? - Ubuntu

I 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 error

Error 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 then library(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 packages

AND

> 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
like image 617
Smackboyg Avatar asked May 22 '14 09:05

Smackboyg


2 Answers

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.

  1. Set a password for the shiny user account using sudo passwd shiny, now enter and confirm a password
  2. Switch to the shiny account using: su - shiny
  3. Call up R using R (without sudo)
  4. 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

like image 125
Bastiaan Quast Avatar answered Nov 15 '22 21:11

Bastiaan Quast


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 editing run_as in /etc/shiny-server/shiny-server.conf. In this case, you may change the second line to run_as your_username shiny;, so that it looks for your .libPaths() and then shiny's .libPaths(). You may also add multiple users here.
like image 44
Boxuan Avatar answered Nov 15 '22 21:11

Boxuan