1

I have this Shiny application that I want to run using the RInno package.

Right now my current problem is that after creating the app and then running compile_iss, I get to the setup of the application. Finally, when the application is launching it gives me the following error:

ERROR: Can't call `runApp()` from within `runApp()`. If your application code contains `runApp()`, please remove it.

My application does not contain runApp() anywhere inside of it.

I have included this code at the end:

 session$onSessionEnded(function() {
    stopApp()
    q("no")
  })

I end my shiny app with:

shinyApp(ui = ui, server = server)

Does anyone know how I can resolve that error?

Added Code:

ui <- fluidPage( 
  titlePanel(""),
                      h5(""),
                      sidebarLayout(
                        sidebarPanel(
                          selectInput("type", "Select Type of Record:",
                                      choices=c('A', 'B', 'C'),
                                      selected="A"),
                          DT::dataTableOutput("responses", width = 300), tags$hr(),
                          textInput("Comment", "Comments:", ""),
                          actionButton("submit", "Submit")),
                        mainPanel(    
                          plotlyOutput("plot")
                        )
                      )
             )


server <- function(input, output, session) {
  mydata <- reactive({
    invalidateLater(30 * 60000,session)
    odbcChannel<- odbcConnect("a", uid, pwd) 
    message <- sqlQuery(odbcChannel, "select a, b,c 
                        from table
                        ")
  #I got rid of all the other stuff, as I figured it was unimportant. Let me know if you need to see more

  })

session$onSessionEnded(function() {
    stopApp()
    q("no")
  })

}
Davie D
  • 43
  • 6

1 Answers1

3

RInno is designed to call runApp() during the app's startup sequence before any of the app's code is run. shinyApp(ui = ui, server = server) is trying to start the app a second time.

A good pre-compile_iss check is to run runApp("path to ui.R/server.R") because that is exactly how RInno tries to start the app

If you delete shinyApp(ui = ui, server = server) from your app, it should fix the error, but let me know if you are still having an issue and I would be happy to troubleshoot it with you!

Jonathan Hill
  • 1,745
  • 15
  • 25
  • I have taken out shinyApp(ui = ui, server = server). The error still appears unfortunately. – Davie D Aug 15 '17 at 20:12
  • 1
    make sure your files have the right names. ui.R and server.R everything else should be sourced in one of these two. @DavieD – HoofarLotusX Aug 15 '17 at 20:13
  • Can you share more of your app's code? Is it using app.R or a combination of ui.R, server.R and global.R? – Jonathan Hill Aug 15 '17 at 20:13
  • Is that file called app.R? – Jonathan Hill Aug 15 '17 at 20:22
  • It was not, I renamed it app. Now I get a different error : ERROR: app.R did not return a shiny.appobj object. Does this have to deal with my shiny code? – Davie D Aug 15 '17 at 20:26
  • 1
    Yep, you should break them out into ui.R and server.R files similar to the example_app – Jonathan Hill Aug 15 '17 at 20:27
  • I have got it to work now, thank you for all the help. – Davie D Aug 15 '17 at 20:59
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/151992/discussion-between-davie-d-and-jonathan-hill). – Davie D Aug 15 '17 at 22:15
  • @JonathanHill can you please look at [this](https://stackoverflow.com/questions/72834154/r-shiny-make-path-location-in-dt-table-column-clickable-and-navigable?noredirect=1#comment128646713_72834154)? It would also be helpful if you could create a tag of your package, thank you. – Ed_Gravy Jul 01 '22 at 22:22