Patrick Stephenson
Patrick Stephenson

Reputation: 98

How to force Heroku to install the leaflet package?

I have a small R Shiny application that runs perfectly on my local machine. I am now trying to deploy it on Heroku using the Heroku buildpack for R.

Everything seems to work well during deployment, and Heroku indicates that the deployment was successful. However, when I try to run the app, it fails because the leaflet package was not installed, despite it being listed in my init.R file.

Here is the relevant part of my init.R file:

# init.R
#
# Example R code to install packages if not already installed
#

my_packages = c("dplyr", "ggplot2","plotly","leaflet","readr")

install_if_missing = function(p) {
  if (p %in% rownames(installed.packages()) == FALSE) {
    install.packages(p, clean=TRUE, quiet=TRUE)
  }
}

invisible(sapply(my_packages, install_if_missing))```

 
**Error: Application Logs**
```2024-09-27T23:23:42.631327+00:00 app[web.1]: Error in library(leaflet) : there is no package called ‘leaflet’
2024-09-27T23:23:42.631328+00:00 app[web.1]: Calls: <Anonymous> ... sourceUTF8 -> eval -> eval -> ..stacktraceon.. -> library
2024-09-27T23:23:42.637364+00:00 app[web.1]: Execution halted
2024-09-27T23:23:42.683040+00:00 heroku[web.1]: Process exited with status 1
2024-09-27T23:23:42.707066+00:00 heroku[web.1]: State changed from starting to crashed```

Upvotes: 0

Views: 52

Answers (0)

Related Questions