Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny App Deployment - Error (cannot change working directory)

Tags:

r

shiny

I have been trying to deploy a shiny app using rsconnect: deployapp(appname = "myapp"). I get the following message at the command prompt:

Application successfully deployed to https://sitename.shinyapps.io/MyApp/

However, when I launch the app, I get the error message:

ERROR: cannot change working directory

Based on resolution to similar problem on both Stackoverflow and googleforum, I tried using both absolute and relative paths in setwd(). Following are the error messages with both absolute and relative paths to setwd():

Error in setwd("~/Data/Projects/MyApp"): cannot change working directory

Error in setwd("C:/Users/Documents/Data/Projects/MyApp"): cannot change working directory

Any suggestions to resolve the issue would be greatly appreciated. thanks in advance!

like image 480
xineers Avatar asked Apr 27 '16 00:04

xineers


People also ask

How do I deploy shiny app to Shinyapps io?

To deploy your application, use the deployApp command from the rsconnect packages. If you're using the RStudio IDE, you can also deploy your application by clicking the Publish button while viewing the application. Once the deployment finishes, your browser should open automatically to your newly deployed application.


1 Answers

shinyapps.io is a virtualized container service running shiny apps.

  1. It is most likely linux based. I do not have the time to write up a shiny app to confirm that but like most virtualized containers let us assume it is.
  2. With 1 being say true. Paths like C:/ do not make sense in the linux world.
  3. Again with 1 in mind the directory structure of ~/Data might not exist.

Work with relative paths ~/ Also put a checkguard with dir.exists() and dir.create

dirname <-  '~/Data/Projects/MyApp'
if (!dir.exists(dirname))dir.create(dirname,recursive=TRUE)

FYI I don't really think your should be doing any setwd() for shinyapps. If the data file is is in ~/Data/Projects/Myapp/somedata.csv you can do a direct read in the app as read.csv('somedata.csv').

The server directory structure is in the form of /srv/shiny-server/MyShinyApp when you upload

like image 85
prateek05 Avatar answered Oct 22 '22 10:10

prateek05