This might be intended behavior but I've been coding in Shiny for 2 years and have never seen any mention of this. Essentially, if you make a Shiny app and have "R" as a folder, all scripts sourced from that folder will run twice whenever the app runs and will be sourced before everything else.
# app.R
library(shiny)
source("R/src1.R")
source("dog/src2.R")
source("R/src3.R")
ui <- fluidPage(
titlePanel(""),
sidebarLayout(
sidebarPanel(),
mainPanel()
)
)
server <- function(input, output) { }
shinyApp(ui = ui, server = server)
# R/src1.R
print("src1")
# dog/src2.R
print("src2")
# R/src3.R
print("src3")
I'm really curious whether anyone else has encountered this behavior ... it took almost a whole evening for me to diagnose and really cut into my development time. Here was my output:
[1] "src1"
[1] "src3"
[1] "src1"
[1] "src2"
[1] "src3"