Installing R packages with Packer

(platform = AWS Amazon Linux 2)

Trying to create an entry in packer.json to install the R shiny package. The command line to install is:

sudo su -
-c “R -e “install.packages(‘shiny’, repos=‘’)””

But this doesn’t work in the packer build file, even when I insert " at the beginning and ", at the end. I know it can work, just need the proper syntax.


We wrote an Rscript to do that, it looks something like this:

#!/usr/bin/env Rscript
  repo = "")

We then copy it with the file provisioner and execute it at boot time.