Some of my shinapps fail to start with "The application exited during initialization" error

I was running several shinyapps on my shiny server hosted on ubuntu (16.04) AWS EC2 instance till yesterday. Today I upgraded my R from 3.5.2 to R 4.0. In the process I removed all old packages and reinstalled all packages in a new libpath.

> .libPaths()
[1] "/R4packages"  "/usr/lib/R/site-library"   "/usr/lib/R/library"

This new path where all R 4.0.1 packages are is: /R4packages

A directory listing with ls -ld / shows up as:
drwxrwxr-- 103 rstudio rstudio 4096 Jun 17 16:21 R4packages

All the shiny apps are running fine from inside rstudio but failing when accessed from the browser as <ip address>:3838/myapp. This used to run earlier.

A major clue is that everytime the shiny server log contains the exact same text for all the apps. Surprisingly the error message points to the package digest while I do not use digest package in most of my apps. Perhaps in a few I used digest but the failure occurs for non digest apps too.

$ tail poll-rstudio-20200617-170252-41173.log

Error in loadNamespace(name) : there is no package called ‘digest’
Calls: local ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted

Just to confirm the package digest is installed in the primary libpath:
x1[grepl("dig",Package),.(Package,Version,LibPath)] # x1 is a data.table containing all installed packages)

Package Version LibPath
1: digest 0.6.25 /R4packages

I have spent several hours tweaking my conf file. None of the changes I did had any affect on the error message. The current version of the conf file is as follows:

$ sudo cat /etc/shiny-server/shiny-server.conf

# adding this line to preserve logs
  preserve_logs true; 

location /home {
run_as :HOME_USER:;
user_dirs;
}
# Define a server that listens on port 3838
server {
 listen 3838;

 # Define a location at the base URL
 location /home/rstudio/ShinyApps {
 run_as rstudio;
# adding this line to avoid the annoying time expiry disconections 
app_idle_timeout 0;

# 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;

}
}

I have changed run_as to rstudio and I have removed user_dirs before adding it back.
Note: site_dir value is untweaked as the apps are all linked into that directory.

My suspicion is that the package directory /R4packages is still not being recognised and digest may be the first package it tried to load every time.

Any pointers at how to troubleshoot this would be highly appreciated.

How have you changed the lib path? for what user have you changed it? Also, why not stick with the standard system library path?

1 Like

Yes indeed. I changed the libpath for user: rstudio to the one I have loaded the packages in i.e. /R4packages. I also have included the run_as rstudio line in the shiny-server.conf. What possibly could go wrong?

I changed the library path away from the standard path to keep it away from the clutter. Easy to change to using cd, and since this server is dedicated for R. Also since there is a config file that allows changes in path we should be able to change it.

What possibly could be going wrong?

I have fiddled with the permissions and paths a lot and therefore am going to post a fresh question. This thread will be referred when needed. Right now there is no solution for this problem.