Problem Building Rstanarm in Shiny

Am not sure this is the right place to post this, please redirect me if so. It’s probably more of a Shiny thing than an rstanarm thing but wanted to double check.

App runs locally (Windows 10) but will no longer build on Shiny. Error message says the problem is building rstanarm. Am running R version 4.0.5, RStudio 1.4.1106, Rstan 2.21.2, Rcpp 1.0.6, RcppEigen 0.3.3.9.1.

Beginning of deployment log:
Preparing to deploy document...DONE
Uploading bundle for document: 3930387...DONE
Deploying bundle: 4447174 for document: 3930387 ...
Waiting for task: 906963124
  building: Parsing manifest
  building: Building image: 5101354
  building: Installing system dependencies
  building: Fetching packages
  building: Building package: bayesplot
  building: Building package: shinystan
  building: Building package: rstanarm
################################ Begin Task Log ################################ 

Error message at end of log:
Eigen::Transpose<Eigen::Matrix<double, -1, 1> > >, Eigen::Matrix<double, -1, -1>, 0>; Rhs = Eigen::Matrix<double, -1, 1>]’
/opt/R/4.0.5/lib/R/library/RcppEigen/include/Eigen/src/Core/ProductEvaluators.h:124:75:   required from ‘Eigen::inte################################# End Task Log ################################# 
Error: Unhandled Exception: Child Task 906963127 failed: Error building image: Error building rstanarm (2.21.1). Build exited with non-zero status: 1
Execution halted

  • Operating System: Windows 10
  • rstanarm Version: 2.21.1

Thanks much in advance.

1 Like

PS I tried repeating this using the default Shiny app template in RStudio for Windows and got the same error. All I did was add library(rstanarm) at the top of the app template as follows.

library(shiny)
library(rstanarm) # I added this as test

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')
})

}

Run the application

shinyApp(ui = ui, server = server)

1 Like

Hi,
sorry for not getting to you earlier. I think this would be some sort of issue with configuration of the server (which appears to be running some kind of Linux) than with your workstation.

For debugging we would need to know a bit more about the server and get the full log - what you’ve sent is just last few lines, but usually in such cases there is much more output (I don’t know enough about shiny to help you get the full log). If the log is long, you can save it in a .txt file and attach to your post.

Tagging @rok_cesnovar who might have seen such an issue before.

Hi,

This might be an old issue but I’m dealing with the same problem right now.
I also tried to run LPA’s simple shiny app example and came up with the same deployment issue.

If it helps, I think I’ve been able to pin it down to the fact that for some reason whenever you try to load the rstanarm library, the shinyapps server tries to install it from source, including the hundreds of .cpp, .cc, etc. files that come with rstanarm and also its many dependencies.

As a (failed) attempt at a workaround I tried installing rstanarm post-deployment. Which succeeds in deploying the app but fails when the app startup eventually runs out of time and shinyapps shuts it down.

This is the error message as seen in the shinyapps logs:

2022-09-07T17:54:02.431883+00:00 shinyapps[6938047]: g++: fatal error: Killed signal terminated program cc1plus
2022-09-07T17:54:02.431954+00:00 shinyapps[6938047]: compilation terminated.
2022-09-07T17:54:02.442793+00:00 shinyapps[6938047]: Container event from container-7151305: oom (out of memory)
2022-09-07T17:57:56.484026+00:00 shinyapps[6938047]: make: *** [/opt/R/4.2.1/lib/R/etc/Makeconf:175: stan_files/mvmer.o] Error 1
2022-09-07T17:57:56.484074+00:00 shinyapps[6938047]: rm stan_files/lm.cc stan_files/mvmer.cc
2022-09-07T17:57:56.484174+00:00 shinyapps[6938047]: * removing ‘/tmp/RtmpsEHyZ6/rstanarm’
2022-09-07T17:57:56.484127+00:00 shinyapps[6938047]: ERROR: compilation failed for package ‘rstanarm’
2022-09-07T18:11:37.449042+00:00 shinyapps[6938047]: Container event from container-7151305: stop

My app is set to xxl (8GB) and a startup timeout of 300 seconds.

A deployment attempt with library(rstanarm)throws the following error:

deploy_error.txt (61.2 KB)

Any help for a workaround on this would be deeply appreciated.