Can't deploying shiny app:Error in setwd(bundleDir) : cannot change woking directory

844 views
Skip to first unread message

Chason Sheng

unread,
Jul 13, 2016, 8:07:36 AM7/13/16
to ShinyApps Users
Hi All,
My first App have some trouble on deploying ,for some help.

I 've followed shinyapps.io steps:

install.packages('rsconnect')

rsconnect::setAccountInfo(name='yeita-intelligence',
			  token='2344E78007590590A38DA4695AE65914',
			  secret='<SECRET>')   #the secret is hiding

library(rsconnect)
rsconnect::deployApp('C:/Users/Chason/Desktop/Cov_test')    # Any questions at this point?

After the step 3, R console pointed the error : "Uploading bundle for application: 114150...Error in setwd(bundleDir) : cannot change working directory"

In shinyapps.io - Applications, the App I deployed is "Undeployed" .


Win 10 , R x64-3.3.1  

additionally, Can I deploy it by Rstudio?

Give me some help, Thank you !


Joshua Spiewak

unread,
Jul 13, 2016, 8:19:23 AM7/13/16
to ShinyApps Users
shinyapps.io runs on Linux, and all paths must be relative, and all files you want to upload with your code should live in the directory tree with the code so it can all be bundled together and deployed.

Yes, the RStudio IDE has a deploy button, right next to the run button.

Chason Sheng

unread,
Jul 13, 2016, 11:00:19 PM7/13/16
to ShinyApps Users
Hi Joshua,
Thank you very much for your reply!
but I didn't know the "relative" , "directory tree" you said . could you tell the method details?

And I found the "pubish" button beside "run" in Rsudio, but it does not word,too .
the error:
"Preparing to deploy application...DONE
Uploading bundle for application: 114318...Error in setwd(bundleDir) : cannot change working directory
Calls: <Anonymous> ... addPackratSnapshot -> performPackratSnapshot -> setwd
Execution halted"

Maybe I'm a beginner or can't understanding your statement in English.  
Thanks again!


在 2016年7月13日星期三 UTC+8下午8:19:23,Joshua Spiewak写道:

Tareef Kawaf

unread,
Jul 14, 2016, 7:03:51 AM7/14/16
to Chason Sheng, ShinyApps Users
Chason,
It may be easier to share a simple application that you are trying to deploy to see if we can help you spot the issue.

In looking at the error you sent it looks like something is trying to run: setwd() which seems suspicious.  

Your applicaiton code shouldn't have any of the install.packages() rsconnect::setAccountInfo() etc...  It should be a ui.R and a server.R and possibly data that you are loading.  That data that you are loading from a file would need to be in a file that is in the same directory as your ui.R file and your server.R files, or in a sub directory

For example:

Your application may be in the directory: C:/Users/Chason/Desktop/Cov_test

Let us assume you have a data directory that is underneath Cov_test, so the data path looks like:  C:/Users/Chason/Desktop/Cov_test/data

If your application has a "setwd() call" it cannot contain the full path, it would need to be a relative path like so:  setwd("data") 
because deploying your application to shinyapps.io means it is running on a server and as such there is no C:/Users/Chason/Desktop.  The aplication will start up as if it is running with Cov_test.

Hope this helps.
-Tareef

--
You received this message because you are subscribed to the Google Groups "ShinyApps Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shinyapps-use...@googlegroups.com.
To post to this group, send email to shinyap...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shinyapps-users/c91b88f9-4aba-40c1-96c4-5e81e574311b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Chason Sheng

unread,
Jul 15, 2016, 2:34:22 AM7/15/16
to ShinyApps Users, chaso...@gmail.com
Hi Tareef,
Thank you for your reply!
 Trying to  share a simple application is good idea. But there's the same error:"Uploading bundle for application: 114581...Error in setwd(bundleDir) : cannot change working directory"....
I guess my files is not proper? so I display the sample code and screenshot of files & Rconsole. 
If this simple application is work, maybe my application will run.
Thank you!

ui.R
require(rCharts)
shinyUI(pageWithSidebar(
  headerPanel("rCharts: Interactive Charts from R | NVD3"),
  
  sidebarPanel(
    selectInput(inputId = "gender",
                label = "Choose Gender",
                choices = c("Male", "Female"),
                selected = "Male"),
    selectInput(inputId = "type",
                label = "Choose Chart Type",
                choices = c("multiBarChart", "multiBarHorizontalChart"),
                selected = "multiBarChart"),
    checkboxInput(inputId = "stack",
                  label = strong("Stack Bars?"),
                  value = FALSE)
  ),
  mainPanel(
    showOutput("myChart", "nvd3")
  )
))


server.R


require(rCharts)
shinyServer(function(input, output) {
  output$myChart <- renderChart({
    hair_eye = as.data.frame(HairEyeColor)
    p6 <- nPlot(Freq ~ Hair, group = 'Eye', data = subset(hair_eye, Sex == input$gender), 
                type = input$type, dom = 'myChart', width = 800)
    p6$chart(color = c('brown', 'blue', '#594c26', 'green'), stacked = input$stack)
    return(p6)
  })
})


screenshot of file & R console:




在 2016年7月14日星期四 UTC+8下午7:03:51,Tareef Kawaf写道:
Reply all
Reply to author
Forward
0 new messages