rsconnect deployed shiny app but crashes. Shiny app runs fine locally though...

I used the rsconnect package in RStudio on a Windows 10 computer to deploy the app called 'spatialepisim'. Deployment was a success as you will see in the below message:

> rsconnect::deployApp('C:/Users/Ashok Krishnamurthy/Desktop/spatialEpisim')
Preparing to deploy application...DONE
Uploading bundle for application: 5413751...DONE
Deploying bundle: 5450117 for application: 5413751 ...
Waiting for task: 1079302894
  building: Processing bundle: 5450117
  building: Parsing manifest
  building: Building image: 6308662
  building: Installing system dependencies
  building: Fetching packages
  building: Building package: cptcity
  building: Building package: rjson
  building: Building package: terra
  building: Building package: raster
  building: Building package: fasterize
  building: Building package: rasterVis
  building: Installing packages
  building: Installing files
  building: Pushing image: 6308662
  deploying: Starting instances
  unstaging: Stopping old instances
Application successfully deployed to https://spatialepisim.shinyapps.io/spatialepisim/

When I open the deployed app on a browser and upload an Excel file for seeddata and select the country: Czech Republic from the dropdown and run the simulation for 5 timesteps the app crashes. On shinyapps.io I found the below Logs

2022-01-10T04:44:32.852013+00:00 shinyapps[5413751]: terra 1.5.9
2022-01-10T04:44:32.858258+00:00 shinyapps[5413751]: 
2022-01-10T04:44:32.845652+00:00 shinyapps[5413751]: 
2022-01-10T04:44:32.845653+00:00 shinyapps[5413751]: 
2022-01-10T04:44:32.858534+00:00 shinyapps[5413751]: The following object is masked from ‘package:rgdal’:
2022-01-10T04:44:32.845652+00:00 shinyapps[5413751]: The following object is masked from ‘package:base’:
2022-01-10T04:44:32.858535+00:00 shinyapps[5413751]:     project
2022-01-10T04:44:33.079039+00:00 shinyapps[5413751]: Enabled features: fontconfig, freetype, fftw, lcms, pango, webp, x11
2022-01-10T04:44:32.868766+00:00 shinyapps[5413751]: Loading required package: lattice
2022-01-10T04:44:32.858535+00:00 shinyapps[5413751]: 
2022-01-10T04:44:32.858258+00:00 shinyapps[5413751]: Attaching package: ‘terra’
2022-01-10T04:44:32.858535+00:00 shinyapps[5413751]: 
2022-01-10T04:44:33.079104+00:00 shinyapps[5413751]: Using 16 threads
2022-01-10T04:44:32.858257+00:00 shinyapps[5413751]: 
2022-01-10T04:44:33.079038+00:00 shinyapps[5413751]: Linking to ImageMagick 6.9.10.23
2022-01-10T04:44:33.079040+00:00 shinyapps[5413751]: Disabled features: cairo, ghostscript, heic, raw, rsvg
2022-01-10T04:44:34.159861+00:00 shinyapps[5413751]: e[0;1;31mSystem has not been booted with systemd as init system (PID 1). Can't operate.e[0m
2022-01-10T04:44:34.159893+00:00 shinyapps[5413751]: e[0;1;31mFailed to create bus connection: Host is downe[0m
2022-01-10T04:44:34.350417+00:00 shinyapps[5413751]: 
2022-01-10T04:44:34.160502+00:00 shinyapps[5413751]: Warning in system("timedatectl", intern = TRUE) :
2022-01-10T04:44:34.350967+00:00 shinyapps[5413751]:     intersect, union
2022-01-10T04:44:34.160503+00:00 shinyapps[5413751]:   running command 'timedatectl' had status 1
2022-01-10T04:44:34.350967+00:00 shinyapps[5413751]: 
2022-01-10T04:44:34.350419+00:00 shinyapps[5413751]: Attaching package: ‘lubridate’
2022-01-10T04:44:34.351205+00:00 shinyapps[5413751]:     date, intersect, setdiff, union
2022-01-10T04:44:34.350420+00:00 shinyapps[5413751]: 
2022-01-10T04:44:34.350723+00:00 shinyapps[5413751]: 
2022-01-10T04:44:34.350721+00:00 shinyapps[5413751]: The following objects are masked from ‘package:terra’:
2022-01-10T04:44:34.351205+00:00 shinyapps[5413751]: 
2022-01-10T04:44:34.350722+00:00 shinyapps[5413751]: 
2022-01-10T04:44:34.350723+00:00 shinyapps[5413751]:     intersect, union
2022-01-10T04:44:34.350965+00:00 shinyapps[5413751]: The following objects are masked from ‘package:raster’:
2022-01-10T04:44:34.351204+00:00 shinyapps[5413751]: 
2022-01-10T04:44:34.350966+00:00 shinyapps[5413751]: 
2022-01-10T04:44:34.351203+00:00 shinyapps[5413751]: The following objects are masked from ‘package:base’:
2022-01-10T04:44:34.731566+00:00 shinyapps[5413751]: WARNING: Illegal reflective access by org.apache.poi.util.SAXHelper (file:/opt/R/4.1.2/lib/R/library/xlsxjars/java/poi-ooxml-3.10.1-20140818.jar) to method com.sun.org.apache.xerces.internal.util.SecurityManager.setEntityExpansionLimit(int)
2022-01-10T04:44:34.731562+00:00 shinyapps[5413751]: WARNING: An illegal reflective access operation has occurred
2022-01-10T04:44:34.731567+00:00 shinyapps[5413751]: WARNING: Please consider reporting this to the maintainers of org.apache.poi.util.SAXHelper
2022-01-10T04:44:34.731568+00:00 shinyapps[5413751]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
2022-01-10T04:44:34.731599+00:00 shinyapps[5413751]: WARNING: All illegal access operations will be denied in a future release
2022-01-10T04:44:40.658990+00:00 shinyapps[5413751]: 
2022-01-10T04:44:40.658992+00:00 shinyapps[5413751]: Listening on http://127.0.0.1:44709
2022-01-10T04:45:12.166731+00:00 shinyapps[5413751]: Warning in gzfile(file, "rb") :
2022-01-10T04:45:12.167690+00:00 shinyapps[5413751]: Warning: Error in gzfile: cannot open the connection
2022-01-10T04:45:12.172627+00:00 shinyapps[5413751]:   13: fn
2022-01-10T04:45:12.166734+00:00 shinyapps[5413751]:   **cannot open compressed file 'gadm/gadm36_cze_1_sp.rds', probable reason 'No such file or directory'**
2022-01-10T04:45:12.172629+00:00 shinyapps[5413751]:    6: eval
2022-01-10T04:45:12.172627+00:00 shinyapps[5413751]:   15: <Anonymous>
2022-01-10T04:45:12.172628+00:00 shinyapps[5413751]:    8: retry
2022-01-10T04:45:12.172629+00:00 shinyapps[5413751]:    7: connect$retryingStartServer
2022-01-10T04:45:12.172630+00:00 shinyapps[5413751]:    5: eval

However the 'gadm/gadm36_cze_1_sp.rds' folder and file does exist and the app runs fine locally. Why is my app crashing ?

My GitHub repo is located here: GitHub - ashokkrish/spatialEpisim: spatialEpisim: Spatial Tracking of Infectious Disease Epidemics using Mathematical Models

Hi,

2022-01-10T04:44:34.160502+00:00 shinyapps[5413751]: Warning in system("timedatectl", intern = TRUE) :
2022-01-10T04:44:34.350967+00:00 shinyapps[5413751]:     intersect, union
2022-01-10T04:44:34.160503+00:00 shinyapps[5413751]:   running command 'timedatectl' had status 1

It seems from the error that your app is trying to perform actions on the system that require elevated permissions. This would explain why things work locally, but not remotely. A post with a similar error was explained that way by an RStudio employee. You should try and figure out which part of your code need to run with elevated permissions and find a workaround...

Hope this helps,
PJ