zip files downloader not working when deployed on shinyapps

Hi All,

I've run into an issue with zipping files for download from a shiny app. This appears to be recent issue and everything was working until this issue being noticed a few days on a deployed app. The app.R code below allows a zipped folder to be downloaded. But when deployed on the zipped folder cannot be downloaded. The logs from show the error:

sh: 1: /usr/bin/zip: not found
Warning in system2(zip, args, input = input) : error in running command

It appears the path to the zip library cannot be found. Adding which zip in the app code below shows a non zero exit ('1') in the logs, I think this means a zip library path cannot be found on the shiny server. Looking at the documented list of installed system dependency in Appendix 10 in the shiny User Guide shows that zip library should be available. It appears something is preventing zip function finding the path to the zip system library on the shiny server? But I have no idea how to fix this.

Any help greatly appreciated, many thanks Tim

ui <- fluidPage(
      downloadButton("downloadData", label = "Download")
    mainPanel(h6("Sample download", align = "center"))
server <- function(input, output) {
  message(paste("zip lib path", system("which zip")))
  output$downloadData <- downloadHandler(
    filename = function() {
      paste("output", "zip", sep = ".")
    content = function(fname) {
      fs <- c()
      tmpdir <- tempdir()
      for (i in c(1, 2, 3)) {
        path <- paste0("sample_", i, ".csv")
        fs <- c(fs, path)
        write(i * 2, path)
      zip(zipfile = fname, files = fs)
    contentType = "application/zip"
# Run the application
shinyApp(ui = ui, server = server)
1 Like

Having a similar error here on one of my apps. Interestingly though, zip downloading appears to be working on a previously deployed app. Going to try and redeploy the app to a new instance and see if zip downloading breaks.

1 Like

I am now pretty confident that this is an issue with something on

These two apps are identical, one was posted today, one was posed months ago. When I click the download zip button I get the same error as you in my logs on the more recent one but the zip downloads immediately.

Next I am going to try adding in the zip library.

1 Like

Ok, so after adding library(zip) now I get another error "Warning: Error in file.exists: invalid 'file' argument", getting closer.

Thanks wincowger, glad to have it independently checked. I'm happy to post an issue on the GitHub - rstudio/shinyapps-package-dependencies: Collection of bash scripts that install R package system dependencies to check if the zip library is being correctly installed on new images on the shiny server. I think that maybe be the next step?

1 Like

Good idea, looks like they updated some of the zip file dependencies in the last month:


Great, well spotted. I'll post an issue over there.

Sounds good, also testing a few other options, directly referencing the packages zip::zip or utils::zip didn't work either.

1 Like

Thanks for verify other options. I also tested a version without setwd() as sometimes changing the working directory can cause problems. I've posted an issue on shinyapps-package-dependencies

Thanks for bringing this to our attention. We will start looking into this issue and post a follow-up message when we know more.

1 Like

zip is now included in the base image again. Going forward, new builds should have it available to use.

1 Like

Many thanks to everyone who helped fix this issue. Been using shinyapps for many years and continues to be a great experience.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.