Shiny not working, attempt to apply non-function

I'm trying to get Shiny to work, but even the built-in examples do not work. They only open a browser page with "An error occurred, attempt to apply a non-function". How can I fix this? See attached screenshot with session info.

afbeelding

I also tried a basic Hello World example copy-pasted from a tutorial, with in "app.R" the following code:

ui <- fluidPage("Hello, world!")
server <- function(input, output, session) {}
shinyApp(ui, server)

This has the same result, with a slightly different error message in RGui:

Warning: Error in mfunc: attempt to apply non-function
  1: shiny::runApp

Have you tried to clear the environment before running an app?

Yeah, this is in a newly started session, nothing is loaded from any workspace either, environment is empty.

I'm wondering about mfunc - afaik there is no mfunc function in shiny.

Hmm, stepping through the runApp function manually, I get the same error but with much more detailed trace when I hit the line utils::browseURL(appUrl), so that's where it seems to be originating from. Though no idea why this would happen here, or how to resolve it.

afbeelding

Well, I tried installing a new version of R (4.2.1), that seems to have resolved the issue. Not sure if it's due to the R version or something in some library installed with my existing 4.0.3, though my guess would be the last one (presumably other people would have run into this already otherwise).

Thanks for the help!

In my case, I just had to update all packages (eg. using Rstudio "update all" feature) to avoid the error.
It sounds like some previous version of one of my packages was the cause. (but cannot find which one anymore:( )

I'm having this same issue, but I've updated all the packages and it still doesn't work.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

This is likely the same issue reported here Error in mfunc: attempt to apply non-function · Issue #458 · rstudio/bslib · GitHub

The best fix is to update to the latest version of {memoise} (>= 2.0.0). If that doesn't seem to work, you can try to downgrade {bslib} to 0.3.0 remotes::install_version("bslib", "0.3.0"). Hopefully one of these two works.

2 Likes