publishing Shiny app with gganimate library

I'm trying to deploy a shiny app with a gganimate function for an animated plot made with user input. But when deploying to the shinyapps.io server i get an error. It seems that the gifski package depends on Rust/ a rust compiler being installed. Is there a way around this?

error from deploy tab:

Preparing to deploy application...DONE
Uploading bundle for application: 597672...DONE
Deploying bundle: 1730667 for application: 597672 ...
Waiting for task: 569219611
  building: Parsing manifest
  building: Building image: 1787246
  building: Building package: gifski
################################ Begin Task Log ################################ 
[2018-11-30T07:22:55.321463131+0000] Installing R package: withr (2.1.2)
* installing to library ‘/opt/R/3.5.0/lib/R/library’
* installing *binary* package ‘withr’ ...
* DONE (withr)
[2018-11-30T07:22:55.525073539+0000] Installing R package: crayon (1.3.4)
* installing to library ‘/opt/R/3.5.0/lib/R/library’
* installing *binary* package ‘crayon’ ...
* DONE (crayon)
[2018-11-30T07:22:55.741485066+0000] Installing R package: viridisLite (0.2.0)
* installing to library ‘/opt/R/3.5.0/lib/R/library’
* installing *binary* package ‘viridisLite’ ...
* DONE (viridisLite)
[2018-11-30T07:22:55.934813003+0000] Installing R package: xtable (1.8-2)
* installing to library ‘/opt/R/3.5.0/lib/R/library’
* installing *binary* package ‘xtable’ ...
* DONE (xtable)
[2018-11-30T07:22:56.163711038+0000] Installing R package: magrittr (1.5)
* installing to library ‘/opt/R/3.5.0/lib/R/library’
* installing *binary* package ‘magrittr’ ...
* DONE (magrittr)
[2018-11-30T07:22:56.361934145+0000] Installing R package: sourcetools (0.1.7)
* installing to library ‘/opt/R/3.5.0/lib/R/library’
* installing *binary* package ‘sourcetools’ ...
* DONE (sourcetools)
[2018-11-30T07:22:56.599020812+0000] Installing R package: labeling (0.3)
* installing to library ‘/opt/R/3.5.0/lib/R/library’
* installing *binary* package ‘labeling’ ...
* DONE (labeling)
[2018-11-30T07:22:56.783184304+0000] Installing R package: rlang (0.2.2)
* installing to library ‘/opt/R/3.5.0/lib/R/library’
* installing *binary* package ‘rlang’ ...
* DONE (rlang)
[2018-11-30T07:22:57.014687325+0000] Installing R package: stringi (1.1.7)
* installing to library ‘/opt/R/3.5.0/lib/R/library’
* installing *binary* package ‘stringi’ ...
* DONE (stringi)
[2018-11-30T07:22:57.379688223+0000] Building R package: gifski (0.8.6)
/mnt/packages/build /mnt
* installing to library ‘/opt/R/3.5.0/lib/R/library’
* installing *source* package ‘gifski’ ...
** package ‘gifski’ successfully unpacked and MD5 sums checked
------------------ RUST COMPILER NOT FOUND --------------------

Cargo was not found on the PATH. Please install cargo / rustc:

 - yum install cargo         (Fedora/CentOS)
 - apt-get install cargo     (Debian/Ubuntu)
 - brew install rustc        (MacOS)

Alternatively install Rust from: <https://www.rust-lang.org>

---------------------------------------------------------------

ERROR: configuration failed for package ‘gifski’
* removing ‘/opt/R/3.5.0/lib/R/library/gifski’################################# End Task Log ################################# 
Error: Unhandled Exception: Child Task 569219612 failed: Error building image: Error building gifski (0.8.6). Build exited with non-zero status: 1
Execution halted

example in shiny with gganimate plot:

library(gapminder)
library(ggplot2)
library(shiny)
library(gganimate)
theme_set(theme_bw())

ui <- basicPage(
  imageOutput("plot1"))

server <- function(input, output) {
  output$plot1 <- renderImage({
    # A temp file to save the output.
    # This file will be removed later by renderImage
    outfile <- tempfile(fileext='.gif')
    
    # now make the animation
    p = ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, 
                              color = continent)) + geom_point() + scale_x_log10() +
      transition_time(year) # New
    
    anim_save("outfile.gif", animate(p)) # New
    
    # Return a list containing the filename
    list(src = "outfile.gif",
         contentType = 'image/gif'
         # width = 400,
         # height = 300,
         # alt = "This is alternate text"
    )}, deleteFile = TRUE)}

shinyApp(ui, server)

So the issue here is that gifski (which is used by gganimate for gif-generation) is an R wrapper around a Rust library, which, it seems from this error message, is not available (the Rust compiler, and, I assume, the gifski library, since it needs a Rust compiler).

Someone else will hopefully be able to chime in as to whether or not it's possible to use on shinyapps.io, but I figured it was worth breaking down the origin of the error.

3 Likes

See this earlier post.

Additionally, for shinyapps.io (as opposed to rstudio.cloud), the documentation covers systems packages needed by R packages and the shinyapps-package-dependencies GitHub repository.

2 Likes

Thanks for the replies. I'll look into it tomorrow.

cargo is now available and gifski should be able to be installed.

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