When saving a non-empty shiny app, RStudio writes an empty file

I am working through this example in the book Mastering Shiny.

I simplified the app to show the problem. This app runs fine.

ui <- fluidPage(
  fluidRow(
    "Distribution 1",
    numericInput("n", label = "n", value = 1000, min = 1),
  )
)
server <- function(input, output, session) {}
shinyApp(ui, server)

Now when I add a line under the numeric input - even if it is commented out - the app doesn't run, for the simple reason that the file is actually empty, even though the contents are shown in RStudio and RStudio says the file is saved!

ui <- fluidPage(
  fluidRow(
    "Distribution 1",
    numericInput("n", label = "n", value = 1000, min = 1),
    # numericInput("mean1", label = "mu", value = 0, step = 0.1),
  )
)
server <- function(input, output, session) {}
shinyApp(ui, server)
PS C:\Users\...\R\shiny_01\app_03> Get-Content .\app.R
PS C:\Users\...\R\shiny_01\app_03>

The problem is actually triggered by the commented line - if I remove or shorten it, it will work again just by sourcing the file, when I add the full line, it fails again.
This sounds like the same issue as here, however I don't find this helpful as the problem appears to be triggered by the contents of the file, so I would like to fully fix it

This topic was automatically closed 21 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.