shinymeta code modal is blank

Hi,

When trying to display code modal in below example, clicking "show code" displays a blank window with no code output. metaRender and renderPlot functions appear to work as plot displays fine, just no code generation when clicking "show code." Has anyone observed this behavior when using shinymeta, or have any guidance on how to further debug?

Thanks,
James

library(shiny)
library(shinymeta)
library(ggplot2)
library(shinyAce)

ui <- fluidPage(
    outputCodeButton(plotOutput("p1"))
)


server <- function(input, output) {

    output$p1 <- metaRender(renderPlot, {
        hist(diamonds$carat)
    })


observeEvent(input$p1_output_code, {
    code <- expandChain(output$p1())
    displayCodeModal(code)
})    

}
shinyApp(ui, server)

Here is some sessionInfo()

sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shinyAce_0.4.1 shinymeta_0.2.0          ggplot2_3.3.0           shiny_1.4.0.9002

I believe the issue lies with the most current version of Shiny - shiny_1.4.0.9002

Installing shiny_1.4.0 appears to resolve things. Any ideas what may be happening in shiny_1.4.0.9002 that's causing shinymeta to break @jcheng ?

Thanks,

James

@cpsievert, any ideas?

The shinymeta package worked fine until upgrading to most recent version of shiny, now when clicking "show code" in the reprex I first receive an error in the R console that states: "The R.cache package needs to create a directory that will hold cache files." Then a Y/n prompt to create the R.cache directory. Entering "Y" will eliminate the error message next time the Shiny app is run, which allows me to click the "show code" button and display the code modal without the error message, however the code modal is blank.

On a similar note, @jcheng do you know the current development status of shinymeta, is the package still experimental or are there any plans for a CRAN release in the near future? I'm building a Shiny app that will go into production for my organization and users need to generate R code based on operations performed in the Shiny GUI.

Shinymeta has worked great in the past for me, but issues like this are a bit worrisome. I really don't know of any other package or method for code generation in Shiny so any suggestions or insight into this is extremely helpful.

Thanks to everyone at R Studio for their great work!
-James

Your reprex appears to work as expected with both the current CRAN and GitHub versions of shiny. If you still have issues with it after running update.packages(), please file an issue here https://github.com/rstudio/shinymeta/issues/new and include your devtools::session_info()

We're hoping shinymeta will go to CRAN sometime this summer, but there are a handful of other exciting shiny features were working on that currently have priority

Thanks for investigating. Happy to hear that shinymeta will be on CRAN this summer and excited for the new Shiny features you are working on. Regarding the issue I brought up, it's a bit strange, I sporadically receive the below R.cache package prompt in the R console when running the Shiny app, entering Y resolves the issue for me and allows the code to be generated in the code modal, however for a colleague of mine (same R environment and package versions), entering Y does eliminate the prompt for subsequent Shiny sessions, but a blank codal modal still appear when clicking "Show Code" and no code is generated.

I'm having a hard time getting to the bottom of this so any ideas on how to further debug are appreciated!

The R.cache package needs to create a directory that will hold cache files. It is convenient to use ‘C:\Users\jcraig\AppData\Local\R\R.cache’ because it follows the standard on your operating system and it remains also after restarting R. Do you wish to create the 'C:\Users\jcraig\AppData\Local\R\R.cache' directory? If not, a temporary directory (C:\Users\jcraig\AppData\Local\Temp\RtmpwTvahl/.Rcache) that is specific to this R session will be used. [Y/n]:

I'm guessing this is related to styler's new caching feature...does this reproduce the issue (on your colleagues machine)?

styler::style_text("1+1")

If so, please file an issue here https://github.com/r-lib/styler

Btw, displayCodeModal() ends up calling formatCode() which ends up calling styler::style_text() (to format the code for display), but you can avoid styler entirely by doing:

displayCodeModal(deparseCode(code))

If that's an issue, just make sure the cache is set up for an existing directory.

  1. Create a cache directory: fs::dir_create("/path/to/cache")
  2. set the cache to this directory with R.cache::setCacheRootPath("/path/to/cache")

You can then also deactivate the cache with styler::cache_deactivate(). Not sure if you need the existing caching directory at all before you call styler::cache_deactivate().