xineers
xineers

Reputation: 109

Shiny App Deployment - Error (cannot change working directory)

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!

Upvotes: 9

Views: 10864

Answers (2)

actiondata old acct
actiondata old acct

Reputation: 21

Error in setwd("c:/nonexistent_directory_path") : cannot change working directory

This error message will be generated when a directory does not exist. Verify that directory does in fact exist (ie: check spelling, typos).

Upvotes: 1

prateek05
prateek05

Reputation: 503

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

Upvotes: 8

Related Questions