App crashes after deployment with package error: package or namespace load failed for ‘rgdal’

Starting to pull my hair out with this one. Any and all help is most appreciated. This is my first Shiny App, and it was working fine both on my desktop and as delpoyed online. I wanted to make a small change to the UI, so deleted the app and reuploaded it - only to be faced with an rgdal package error. Part of my app is a function that converts the projection of some point coordinates using sp::spTransform(), which requires rgdal - hence the need for the package.

Here's a copy of the error from the application log:

2019-05-14T23:15:11.134452+00:00 shinyapps[930020]: Warning: Error in : package or namespace load failed for ‘rgdal’ in dyn.load(file, DLLpath = DLLpath, ...):
2019-05-14T23:15:11.146676+00:00 shinyapps[930020]:  unable to load shared object '/opt/R/3.6.0/lib/R/library/rgdal/libs/rgdal.so':
2019-05-14T23:15:11.084725+00:00 shinyapps[930020]:  Polygon checking: TRUE 
2019-05-14T23:15:11.146588+00:00 shinyapps[930020]:   66: value[[3L]]
2019-05-14T23:15:11.146590+00:00 shinyapps[930020]:   65: tryCatchOne
2019-05-14T23:15:11.146592+00:00 shinyapps[930020]:   63: tryCatch
2019-05-14T23:15:11.146591+00:00 shinyapps[930020]:   64: tryCatchList
2019-05-14T23:15:11.146674+00:00 shinyapps[930020]: Error : package or namespace load failed for ‘rgdal’ in dyn.load(file, DLLpath = DLLpath, ...):
2019-05-14T23:15:11.146593+00:00 shinyapps[930020]:   62: library
2019-05-14T23:15:11.146677+00:00 shinyapps[930020]:   /opt/R/3.6.0/lib/R/library/rgdal/libs/rgdal.so: undefined symbol: _ZN10OGRFeature11SetGeometryEP11OGRGeometry

The output of rsconnect::appDependencies() is:

    rsconnect::appDependencies()
         package  version source
1             BH 1.69.0-1   CRAN
2            DBI    1.0.0   CRAN
3             DT      0.6   CRAN
4           MASS 7.3-51.4   CRAN
5         Matrix   1.2-17   CRAN
6             R6    2.4.0   CRAN
7   RColorBrewer    1.1-2   CRAN
8           Rcpp    1.0.1   CRAN
9        askpass      1.1   CRAN
10    assertthat    0.2.1   CRAN
11     backports    1.1.4   CRAN
12     base64enc    0.1-3   CRAN
13         broom    0.5.2   CRAN
14         callr    3.2.0   CRAN
15    cellranger    1.1.0   CRAN
16           cli    1.1.0   CRAN
17         clipr    0.6.0   CRAN
18    colorspace    1.4-1   CRAN
19        crayon    1.3.4   CRAN
20     crosstalk    1.0.0   CRAN
21          curl      3.3   CRAN
22    data.table   1.12.2   CRAN
23        dbplyr    1.4.0   CRAN
24        digest   0.6.18   CRAN
25         dplyr  0.8.0.1   CRAN
26      ellipsis    0.1.0   CRAN
27      evaluate     0.13   CRAN
28         fansi    0.4.0   CRAN
29       forcats    0.4.0   CRAN
30            fs    1.3.1   CRAN
31      generics    0.0.2   CRAN
32       ggplot2    3.1.1   CRAN
33          glue    1.3.1   CRAN
34        gtable    0.3.0   CRAN
35         haven    2.1.0   CRAN
36         highr      0.8   CRAN
37           hms    0.4.2   CRAN
38     htmltools    0.3.6   CRAN
39   htmlwidgets      1.3   CRAN
40        httpuv    1.5.1   CRAN
41          httr    1.4.0   CRAN
42      jsonlite      1.6   CRAN
43         knitr     1.22   CRAN
44      labeling      0.3   CRAN
45         later    0.8.0   CRAN
46       lattice  0.20-38   CRAN
47      lazyeval    0.2.2   CRAN
48     lubridate    1.7.4   CRAN
49      magrittr      1.5   CRAN
50      markdown      0.9   CRAN
51          mgcv   1.8-28   CRAN
52          mime      0.6   CRAN
53        modelr    0.1.4   CRAN
54       munsell    0.5.0   CRAN
55          nlme  3.1-139   CRAN
56       openssl      1.3   CRAN
57        pillar    1.4.0   CRAN
58     pkgconfig    2.0.2   CRAN
59         plogr    0.2.0   CRAN
60          plyr    1.8.4   CRAN
61   prettyunits    1.0.2   CRAN
62      processx    3.3.1   CRAN
63      progress    1.2.1   CRAN
64      promises    1.0.1   CRAN
65            ps    1.3.0   CRAN
66         purrr    0.3.2   CRAN
67         rJava   0.9-11   CRAN
68         readr    1.3.1   CRAN
69        readxl    1.3.1   CRAN
70       rematch    1.0.1   CRAN
71        reprex    0.2.1   CRAN
72      reshape2    1.4.3   CRAN
73         rgdal    1.4-3   CRAN
74         rgeos    0.4-3   CRAN
75         rlang    0.3.4   CRAN
76     rmarkdown     1.12   CRAN
77    rstudioapi     0.10   CRAN
78         rvest    0.3.3   CRAN
79        scales    1.0.0   CRAN
80       selectr    0.4-1   CRAN
81         shiny    1.3.2   CRAN
82   sourcetools    0.1.7   CRAN
83            sp    1.3-1   CRAN
84       stringi    1.4.3   CRAN
85       stringr    1.4.0   CRAN
86           sys      3.2   CRAN
87        tibble    2.1.1   CRAN
88         tidyr    0.8.3   CRAN
89    tidyselect    0.2.5   CRAN
90     tidyverse    1.2.1   CRAN
91       tinytex     0.13   CRAN
92          utf8    1.1.4   CRAN
93         vctrs    0.1.0   CRAN
94   viridisLite    0.3.0   CRAN
95       whisker    0.3-2   CRAN
96         withr    2.1.2   CRAN
97          xfun      0.7   CRAN
98          xlsx    0.6.1   CRAN
99      xlsxjars    0.6.1   CRAN
100         xml2    1.2.0   CRAN
101       xtable    1.8-4   CRAN
102         yaml    2.2.0   CRAN
103      zeallot    0.1.0   CRAN

I've tried reinstalling rgdal, and installing the previous version of rgdal. I've tried reinstalling sp and its dependencies. I've tried reinstalling R and R Studio. I've tried reinstalling Shiny its dependencies. Any help on further troubleshooting would be most helpful!

Here's the UI:

library(shiny)
library(DT)
library(data.table)

ui <- fluidPage(
  
  titlePanel(p("Rborist Master v1.0", style = "color:#577431")),
  
  sidebarLayout(
    sidebarPanel(
      
      
      
      #file inputs and ui set-up----
      fileInput(inputId = "filedata", label = "Upload data. Choose csv file",
                multiple = FALSE,
                accept = c("text/csv",
                           "text/comma-separated-df,text/plain",
                           ".csv")),
      
      hr(),
      h4("Filter Data"),
      
      h5("Assesor choices will appear after data upload."),
      uiOutput("choose_assessor"),
      
      dateRangeInput('dateRange',
                     label = 'Date range input: yyyy-mm-dd',
                     start = Sys.Date() - 2, end = Sys.Date() + 2
      ),
      
      hr(),
      h4(" Convert Coordinates"),
      
      actionButton("convertcoords", label = "Convert Coordinates to UTM"),
      
      hr(),
      h4("Create Excel from Filtered Data"),
      
      actionButton("create_excel", label = "Create Excel"),
      
      hr(),
      h4("Download Inventory"),
      
      downloadButton("download_excel", label = "Download"),
      h5("Once downloaded, CTRL + ALT + SHIFT + F9 rechecks all formula dependencies and recalculates all formulas"),
    
    mainPanel(
      DTOutput(outputId = "table")
    )
  )
  
  
)

And the server, where the convert coordinates function is called. There's another larger function, create.excel(), that is called by the server, but this doesn't have any rgdal dependent code, so for now I'm leaving it out.

    # V1.0

library(sp)
library(rgeos)
library(rgdal)
library(tidyverse)
library(xlsx)
library(shiny)
library(DT)
library(data.table)


# conjunction junction what's your function? --------------------------------------------------------------------------

# convert coords funtion

convert_coords <- function(z){
  
  coordinates(z) <- ~x+y
  
  z@proj4string <- CRS("+init=epsg:4326")
  
  z <- spTransform(z, CRS("+init=epsg:26910"))
  
  z@data$utm_x <- coordinates(z)[,1]
  
  z@data$utm_y <- coordinates(z)[,2]
  
  z <- z@data
  
  return(z)
}

# create excel funtion

source("create_excel_function.R", verbose = F,local = T)



server <- function(input, output) {
  
  
  #  DATA UPLOAD, FILTERING, TABLE RENDERING -------------------------------------------------------------
  
  #read in inventory from UI----
  
  df <- reactive({
    
    req(input$filedata)
    data <- read_csv(input$filedata$datapath)
    
    date_string <- str_split(data$EditDate," ",n = 2,simplify = T)[,1]
    
    data <- data %>%
      mutate(date = as.Date(str_split(EditDate," ",n = 2,simplify = T)[,1],("%m/%d/%Y")))
    
    data
    
  })
  
  # apply assessor and date filters ----
  
  output$choose_assessor <- renderUI({
    
    data <- df()
    
    filter.var <- data$Assessor
    
    if (is.factor(data)) {
      options <- levels(filter.var)
    } else {
      options <- unique(filter.var[order(filter.var)])
    }
    
    checkboxGroupInput("assessor", "Choose Assessor", 
                       choices = options, 
                       selected = NULL)
  })
  
  
  filtered_data <- reactive({
    
    data1 <- df()
    
    data1 <- data1 %>% 
      filter(Assessor %in% input$assessor)
    
    print(head(data1))
    
    return(data1)
    
  })
  
  filtered_data2 <- reactive({
    
    data3 <- filtered_data()
    
    data3 <- data3 %>% 
      filter(date >= input$dateRange[1] & date <= input$dateRange[2])
    
    print(head(data3))
    
    return(data3)
    
  })
  
  # render table ----
  output$table <- renderDT({
    
    tabledata <- filtered_data2()
    
    tabledata <- tabledata %>%
      select(date,Assessor,Tag,`Tree Species`,Species_comment,DBH,Condition,
             `Site Comments`,`Root Comments`,`Trunk Comments`,`Crown/Branch Comments`,x,y)
    
  })
  
  
  observeEvent(input$convertcoords,{
    
    req(input$filedata)
    
    data4 <- filtered_data2()
    
    data4 <- convert_coords(data4)
    
    DT::replaceData(
      DT::dataTableProxy('table'),
      data4 %>%
        select(date,Assessor,Tag,`Tree Species`,Species_comment,DBH,Condition,
               `Site Comments`,`Root Comments`,`Trunk Comments`,`Crown/Branch Comments`,utm_x,utm_y)
    )
  })
  
  # convert coordinates ----
  filtered_data3 <- eventReactive(input$convertcoords,{
    
    req(input$filedata)
    
    data4 <- filtered_data2()
    
    data4 <- convert_coords(data4)
    
    return(data4)
    
  })
  
  # CREATE EXCEL ---------------------------------------------------------------
  
  template <- eventReactive(input$create_excel,{
    
    req(input$filedata)
    
    exceldata <- filtered_data3()
    
    print(exceldata)
    
    # source("create_excel_function.R")
    
    excel_out <- create.excel(exceldata)
    
    print(excel_out)
    
    return(excel_out)
    
  })
  
  # EXPORT/DOWNLOAD DATA -----------------------------------------------------------------------
  
  output$download_excel <- downloadHandler(
    filename = function() {
      paste(Sys.Date(),"_TreeInventory_2019",".xlsm",sep="")
    },
    content = function(file) {
      template <- template()
      xlsx::saveWorkbook(template,file)
    }
  )
  
}

I'm not too experienced in the ways of asking R questions, so I ask your mercy with regard to formatting and possible lack of reproducible error.

Thanks!

1 Like

I have exactly the same issue. Waiting for response from the shinyapps.io people.

3 Likes

Hi, I have exactly the same problem in a MacOS installation since yesterday without any apparent reason. Everything works fine locally, but crashes when I upload to shinyapps. After loosing my mind over this, I reinstalled everything from scratch (cleaned all macports, new R, new R studio, new jdk). I even installed everything in a Windows machine just to get the exact same message from the shiny app web site:

Error in value[3L] :
package or namespace load failed for ‘rgdal’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/opt/R/3.6.0/lib/R/library/rgdal/libs/rgdal.so':
/opt/R/3.6.0/lib/R/library/rgdal/libs/rgdal.so: undefined symbol: _ZN10OGRFeature11SetGeometryEP11OGRGeometry
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne ->
Execution halted

rsconnect::appDependencies()
package version source
1 BH 1.69.0-1 CRAN
2 DBI 1.0.0 CRAN
3 KernSmooth 2.23-15 CRAN
4 MASS 7.3-51.4 CRAN
5 Matrix 1.2-17 CRAN
6 R6 2.4.0 CRAN
7 RColorBrewer 1.1-2 CRAN
8 Rcpp 1.0.1 CRAN
9 V8 2.2 CRAN
10 askpass 1.1 CRAN
11 assertthat 0.2.1 CRAN
12 backports 1.1.4 CRAN
13 base64enc 0.1-3 CRAN
14 class 7.3-15 CRAN
15 classInt 0.3-3 CRAN
16 cli 1.1.0 CRAN
17 clipr 0.6.0 CRAN
18 colorspace 1.4-1 CRAN
19 cowplot 0.9.4 CRAN
20 crayon 1.3.4 CRAN
21 crosstalk 1.0.0 CRAN
22 curl 3.3 CRAN
23 digest 0.6.18 CRAN
24 dplyr 0.8.1 CRAN
25 e1071 1.7-1 CRAN
26 fansi 0.4.0 CRAN
27 foreign 0.8-71 CRAN
28 geojson 0.3.2 CRAN
29 geojsonio 0.7.0 CRAN
30 ggplot2 3.1.1 CRAN
31 glue 1.3.1 CRAN
32 gridExtra 2.3 CRAN
33 gtable 0.3.0 CRAN
34 hms 0.4.2 CRAN
35 htmltools 0.3.6 CRAN
36 htmlwidgets 1.3 CRAN
37 httpuv 1.5.1 CRAN
38 httr 1.4.0 CRAN
39 jqr 1.1.0 CRAN
40 jsonlite 1.6 CRAN
41 labeling 0.3 CRAN
42 later 0.8.0 CRAN
43 lattice 0.20-38 CRAN
44 lazyeval 0.2.2 CRAN
45 leaflet 2.0.2 CRAN
46 magrittr 1.5 CRAN
47 maptools 0.9-5 CRAN
48 markdown 0.9 CRAN
49 mgcv 1.8-28 CRAN
50 mime 0.6 CRAN
51 munsell 0.5.0 CRAN
52 nlme 3.1-140 CRAN
53 openssl 1.3 CRAN
54 pillar 1.4.0 CRAN
55 pkgconfig 2.0.2 CRAN
56 plogr 0.2.0 CRAN
57 plyr 1.8.4 CRAN
58 png 0.1-7 CRAN
59 promises 1.0.1 CRAN
60 protolite 1.8 CRAN
61 purrr 0.3.2 CRAN
62 rJava 0.9-11 CRAN
63 raster 2.8-19 CRAN
64 readr 1.3.1 CRAN
65 reshape2 1.4.3 CRAN
66 rgdal 1.4-3 CRAN
67 rgeos 0.4-3 CRAN
68 rlang 0.3.4 CRAN
69 scales 1.0.0 CRAN
70 sf 0.7-4 CRAN
71 shiny 1.3.2 CRAN
72 shinydashboard 0.7.1 CRAN
73 sourcetools 0.1.7 CRAN
74 sp 1.3-1 CRAN
75 stringi 1.4.3 CRAN
76 stringr 1.4.0 CRAN
77 sys 3.2 CRAN
78 tibble 2.1.1 CRAN
79 tidyr 0.8.3 CRAN
80 tidyselect 0.2.5 CRAN
81 units 0.6-3 CRAN
82 utf8 1.1.4 CRAN
83 vctrs 0.1.0 CRAN
84 viridis 0.5.1 CRAN
85 viridisLite 0.3.0 CRAN
86 withr 2.1.2 CRAN
87 xlsx 0.6.1 CRAN
88 xlsxjars 0.6.1 CRAN
89 xtable 1.8-4 CRAN
90 yaml 2.2.0 CRAN
91 zeallot 0.1.0 CRAN

1 Like

Try turning off package cache from the app's advanced settings in shinyapps.io then redeploy, this seemed to fix my issues.

1 Like

That's done it! A simple switch. Thanks very much.

Remember to switch it back on to speed up future deployments.

Totally worked!!! Thank you! Tried to switch it back right after the first build, but it still failed -- don't understand why.

Yeah my app crashed after activating it again, strange. I am waiting to hear back from support about this.

Yeah. Keep us posted please, because this might happen in the future when other packages (besides rgdal) break.

2 Likes

I am also having this issue. Just changed a few UI features and now getting this exact error. Turning the package cache off did not help in my case. Help with this issue is greatly appreciated.

Same issue. Turning off the package cache does fix it for me, but then it takes forever to redeploy.

I have purged our cache of rgdal, sp, rgeos, and lattice. They will be rebuilt on demand. Hopefully this will resolve whatever the underlying issue might be.

Could it be possible to also check the packages on

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.