0
votes

I have installed Shiny Server in my local machine following the steps here.

I also manage to get the default sample app running at http://127.0.0.1:3838/sample-apps/hello/

But when I want to run the app that I have been working on RStduio, I get this error,

An error has occurred

The application failed to start.

The application exited during initialization.

Error in library(plyr) : there is no package called ‘plyr’ Calls: runApp ... sourceUTF8 -> eval -> eval -> ..stacktraceon.. -> library Execution halted

I have installed all the packages via RStudio and they are in this directory,

/home/tealou/R/x86_64-pc-linux-gnu-library/3.2/

I can see plyr is already installed.

.../3.2/
      plyr/

But why the Shiny Server does not pick up the packages in the directory above?

Where should I install the packages for the server then? and how?

Any ideas?

EDIT:

# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;

# Define a server that listens on port 3838
server {
  listen 3838;

  # Define a location at the base URL
  location / {

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.
    directory_index on;
    PATH=/home/tealou/R/x86_64-pc-linux-gnu-library/3.2/
  }
}
2

2 Answers

1
votes

Does you shiny-server.conf file knows where to look for R installation in your system?

Please, read this:

Shiny Server expects that R is available as an executable named R and is in the PATH of the user which you run shiny-server as. Note that on some CentOS systems, the PATH will be overridden by the startup script to /sbin:/usr/sbin:/bin:/usr/bin. On such systems, if R is not available in one of these locations (regardless of the user's PATH), you'll need to adjust the startup script.

To allow Shiny Server to search for R in additional locations, you'll alter the file in /etc/init.d/shiny-server or /etc/init/shiny-server.conf depending on which startup system you're using (as discussed in Stopping and Starting. You can either adjust the PATH variable to include the directory where R will be found, or you can set an environment variable named R to tell Shiny Server exactly where it should look for the executable.

If you choose to adjust the PATH, you can add the directory in which the executable named R is found to the line that defines the PATH environment variable (PATH=/sbin:/usr/sbin:/bin:/usr/bin).

and more is available here: https://rstudio.github.io/shiny-server/latest/#configuration-settings

And one obvious question just in case: you have library(plyr) in your code, right?

0
votes

As shiny-server runs on a shinyuser the best way to provide any package is to install it for all users by:

sudo su - -c "R -e \"install.packages(c('plyr'), repos='http://cran.rstudio.com/')\""

By this solution you don´t need to make any changes on your conf files.