Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give warning when runApp is called within runApp #1358

Closed
burgerga opened this issue Sep 2, 2016 · 3 comments
Closed

Give warning when runApp is called within runApp #1358

burgerga opened this issue Sep 2, 2016 · 3 comments

Comments

@burgerga
Copy link

burgerga commented Sep 2, 2016

EDIT: sorry, figured out the real problem, the 'Run App' button calls runApp with as argument the directory, however if you have an app.R with some custom shinyApp calls it fails. So in the example below if you simple select all and execute, it works fine. But you should not use the 'Run App' button.

In the documentation for shinyApp one of the examples shows how to make a shinyApp from an 'an explicit UI/server pair', however this example doesn't work. The example in question is

app <- shinyApp(
  ui = fluidPage(
    numericInput("n", "n", 1),
    plotOutput("plot")
  ),
  server = function(input, output) {
    output$plot <- renderPlot( plot(head(cars, input$n)) )
  }
)

runApp(app)

which fails with

Listening on http://127.0.0.1:3280
Warning: Error in handlers$add: Key / already in use
Stack trace (innermost first):
    43: handlers$add
    42: handlerManager$addHandler
    41: startApp
    40: runApp
     1: shiny::runApp
Error in handlers$add(handler, key, tail) : Key / already in use
@burgerga burgerga changed the title shinyApp provided example does not work shinyApp provided example does not work when clicking "Run App" Sep 2, 2016
@burgerga burgerga changed the title shinyApp provided example does not work when clicking "Run App" Behavior of "Run App" button in RStudio unclear Sep 2, 2016
@wch
Copy link
Collaborator

wch commented Sep 3, 2016

This works fine for me. I've seen that error before when reloading shiny in a development session. If you used install_github, something similar may have happened. Try restarting your R session and running it again.

@wch
Copy link
Collaborator

wch commented Sep 3, 2016

Oh wait, I just saw your edit. So you're calling runApp() inside of another runApp()? If that's the case, we could provide a more informative error message.

@burgerga
Copy link
Author

burgerga commented Sep 3, 2016

Yes, I think that's what's happening. Would also explain the error the error message, since / is the default argument for uiPattern and then it tries to start 2 apps, both with uiPattern = "/". But I agree that the error could be clearer.

PS What I ended up doing is renaming the file (no longer app.R), then the button goes away ;)

@jcheng5 jcheng5 changed the title Behavior of "Run App" button in RStudio unclear Give warning when runApp is called within runApp Nov 17, 2016
@wch wch assigned wch and bborgesr and unassigned wch Nov 17, 2016
@bborgesr bborgesr added review and removed targeted labels Nov 23, 2016
bborgesr added a commit that referenced this issue Dec 15, 2016
…e of an app's app.R (or inside ui.R or server.R).
@wch wch closed this as completed in #1482 Dec 16, 2016
wch added a commit that referenced this issue Dec 16, 2016
Fixes #1358: more informative error message when calling runApp inside of an app's app.R
@wch wch removed the review label Dec 16, 2016
@alandipert alandipert added Platform: Windows Bug discovered on Windows that may only repro on Windows Type: Bug 🐛 labels Apr 26, 2019
@alandipert alandipert removed Platform: Windows Bug discovered on Windows that may only repro on Windows Type: Bug 🐛 labels Apr 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants