0

I have several large shiny apps which perfectly work on my local computer, but do not on my shiny server as it seems impossible to load most of the installed packages.

I work with the package renv since I want to avoid dependency problems between the packages used in the different shiny apps. So all my nessecary packages are contained within a folder renv from which I want to load them to run my app:

enter image description here

Minimal working example:

# change path to library
.libPaths("/home/yvs/ShinyApps/test2/renv/library/R-3.6/x86_64-w64-mingw32")

# load packages
library(shiny)
library(DBI)
library(RPostgreSQL)
library(shinyalert)

# run app
shinyApp(
    ui = fluidPage(
      column(4,
        numericInput("x", "Value", 5),
        br(),
        actionButton("button", "test"),
        br(),
        textOutput("text")
      ),
      column(8, 
        tableOutput("table")),
        useShinyalert()
    ),
    server = function(input, output) {
      observeEvent(input$button, {
        cat("Showing", input$x, "rows\n")
        shinyalert("yeah!")
      })
      df <- eventReactive(input$button, {
        head(cars, input$x)
      })
      output$table <- renderTable({
        df()
      })
      output$text <- renderText(
        paste0(.libPaths()) # display path to library
    )
    }
)

This error message appears in my log-file when I call the corresponding http-page:

Fehler: package or namespace load failed for ‘RPostgreSQL’ in library.dynam(lib, package, package.lib):
 shared object ‘RPostgreSQL.so’ not found
Ausführung angehalten

When I mark library(RPostgreSQL) as comment, I can run the app with no error. Since all packages shiny, DBI, RPostgreSQL and shinyalert are only available within my renv-folder (and not within the default shiny library), I assume that loading packages via the command .libPaths() seems to work. Thus, I don't think it is only a permission problem (I do not owe admin rights or the permission to run/log in as user shiny.

Moreover I do not think that this problem is limited to the package RPostgreSQL as I attempted to load many different packages.

It worked with the following packages: shiny leaflet stats utils graphics DBI shinycssloaders shinyalert shinyjs DT.

It did not work with the following packages: sp plotly RPostgreSQL postGIStools dplyr lubridate devtools rCharts rjson yaml config.

I am aware of at least the following two similar issues:

However, neither of them helped to solve my problems.

Both my local computer and the shiny server use R 3.6.3.

Any help much appreciated!

manumanul
  • 35
  • 5
  • How did you install packages to the server? Also, the OS of the server and your computer may help. – Kota Mori Jul 15 '20 at 06:47
  • well, actually I just copied my renv-folder (containing all the packages) to the filesystem of my server. this might not be a proper installation, but since roughly 50% of the packages could be loaded that way i assume it still seems to work. I work with windows10. – manumanul Jul 15 '20 at 07:00
  • I see. Do you have no right to install packages on the server? If you can, that would be a safer option. If the dependency is your concern, you can install with `install.packages(..., lib=...)` to specify a package folder for each app. – Kota Mori Jul 15 '20 at 08:05
  • If installation on the server is not an option, the error seems to be related to loading compiled code (`*.so` file), and the successful libraries seem those do not load one (I quickly checked `library(` and then `library.dynam()`). One thing you can check is which .so file your local computer is reading and what file the R on the server is looking for. – Kota Mori Jul 15 '20 at 08:06
  • I found that my server is indeed looking for these complied file in the wrong place. According to https://stackoverflow.com/questions/41494585/setting-ld-library-path-from-inside-r I tried to load the necessary file by ```dyn.load("/home/yvs/ShinyApps/test2/renv/library/R-3.6/x86_64-w64-mingw32/RPostgreSQL/libs/x64/RPostgreSQL.dll")```. However, it gives me an error saying it to be an *invalid ELF header*. So maybe there is no other solution than proper installation on the server as shiny/admin. – manumanul Jul 16 '20 at 12:06

0 Answers0