Reputation: 316
I can not run a shiny app, neither by the RStudio's button "Run App" or directly with the code runApp()
I've been using this shiny app for many years. But recently, without any changes, the app stop working when I press the button "Run App" in RStudio. Then I enter the command runApp() and it doesn't work neither.
When I press the RStudio button "Run App" I get:
runApp('')
Error in shinyAppDir(x) : No Shiny application exists at the path ""
When I enter the command shiny::runApp()
at the beginning of the app, I get:
Listening on http://127.0.0.1:3642
Warning: Error in runApp: Can't call `runApp()` from within `runApp()`. If your application code contains `runApp()`, please remove it.
51: stop
50: runApp
Error in runApp() :
Can't call `runApp()` from within `runApp()`. If your application code contains `runApp()`, please remove it.
The working directory is good.
So, I'm stuck. I can not run the app.
Upvotes: 5
Views: 11386
Reputation: 506
Late answer, but still a relevant post. I came across the same issue where the runApp command did not produce the application. Pressing esc
in the console reset things and fixed the problem.
Upvotes: 1
Reputation: 1
I've seen the second error before. I was attempting to solve a different problem when I launched a shiny app. There was a button in it which, on click, had the command runApp
to launch another shiny app. That's when I got the error.
A shiny app cannot be called from within another shiny app.
Try adding R file path/ name in runApp
command. Example: runApp("test.R")
Create a new R file run.R in the same directory as shiny app. In run.R, type this:
library (shiny)
runApp("test.R")
Run this file like a normal R process.
shinyApp(ui = ui, server = server)
in the original shiny app.Upvotes: 0
Reputation: 316
I just realize that the problem happens when I open RStudio opening the app directly; in this case, RStudio automatically recognizes the working directory as the directory where the app is.
But if I open RStudio first (for example, from the Desktop icon) or the working directory is different from the directory where the app is, I don't have any issue: the "Run App" button in RStudio works perfectly.
I think the button depends on the working directory, if the working directory is different from the app directory, the buttom automatically adds the path so the app can run. But, if the working directory is the same as the app directory, the button removes the path, leaving an empty space inside runApp() and then causing the problem.
Upvotes: 1