I have a recurrent problem that I simply cannot get apps to work on shinyapps.io. They deploy from RStudio without problem, but then the app on shinyapps.io gives "The application failed to start. exit status 1". All apps work fine when run locally.
The error in the log shows:
Error in enforcePackage(name, curVersion) :
The shiny package was not found in the library.
It does not work even for the simple example shiny app, with the following code:
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white',
xlab = 'Waiting time to next eruption (in mins)',
main = 'Histogram of waiting times')
})
}
# Run the application
shinyApp(ui = ui, server = server)
For some reason, it works fine if I deploy from a different computer. But it will not deploy from my main computer. I have tried changing the location of the app and changing the file encoding. I have checked the package repository is correct with:
options("repos")
$repos
CRAN
"https://cran.rstudio.com/"
attr(,"RStudio")
[1] TRUE
When delpoying it alwasy gives "Found 0 dependencies", even if there are several packages/dependencies. When run on a different computer, it deploys correctly and finds the packages/dependencies. So I can't understand why it is not installing the packages on shinyapps when I deploy from this computer.