rstudio / shinymeta

Record and expose Shiny app logic using metaprogramming
https://rstudio.github.io/shinymeta
223 stars 14 forks source link

Warning: Unable to infer variable name for metaReactive because no srcref is available. #108

Closed zsigmas closed 6 months ago

zsigmas commented 2 years ago

Following shinymeta advice:

Warning: Unable to infer variable name for metaReactive because no srcref is available. Please report an issue to https://github.com/rstudio/shinymeta/issues/new

What information do you need on my side for addressing this?

Thanks!

jcheng5 commented 2 years ago

Thanks for the report. Is your Shiny code in an app.R, or in a package? If app.R, what editor are you using and how exactly are you launching the app?

zsigmas commented 2 years ago

Hello Joe,

Thanks for your quick answer!

The app is contained in a package and effectively, what I am calling is shinyApp with a bit of golem which boils down to this:

exported_run_app <- function(...){

### Some code to customize the ui and server functions

golem::with_golem_options(
      app = shiny::shinyApp(
        ui = ui_func,
        server = server_func,
        enableBookmarking = "url"
      ),
      golem_opts = option_list
    )
}

The app would be called with:

my_package::exported_run_app(my_customizing_parameters)

Let me know if you need any more information

jcheng5 commented 2 years ago

OK. It seems like the package is being built without srcrefs. There’s an option to turn it on if you’re building in RStudio: https://community.rstudio.com/t/why-should-i-build-with-with-keep-source/52542

zsigmas commented 2 years ago

Thanks a lot. I am creating some packages that use shinymeta and are imported by the main package, the one running the app. Should those packages also be built using the keep source option?

jcheng5 commented 2 years ago

Sounds complicated... what I'd actually do is, when calling metaReactive() and similar functions from any package, pass in an explicit varname argument. This frees shinymeta from having to look at the source refs at all.

For example:

my_data <- metaReactive({
  # code goes here...
}, varname = "my_data")
zsigmas commented 2 years ago

Understood, thanks a lot Joe!