I have deployed my plumber.r API file on DigitalOcean using plumberDeploy::do_deploy_api and I get the resulting Swagger documentation with all the functions contained. The majority of functions work perfectly but the functions that uses a htmlwidget serializer, such as plotly works locally but not on the DigitalOcean droplet.
The API function can look like this:
#* Return interactive plot using plotly
#* @serializer htmlwidget
#* @get /plotly
function() {
p <- ggplot(data = diamonds,
aes(x = cut, fill = clarity)) +
geom_bar(position = "dodge")
ggplotly(p)
}
All loaded packages inside the plumber.R file have been double checked to be installed on the droplet.
The error produced is a 500: Internal Server Error, An exception has occurred.. No matter how I try to debug that error message, with tryCatch, turning on plumber's debug mode, or setting a custom error message with pr_set_error, I get no information as to why this error occurs.
Does anyone have any suggestions on where to look?
After looking into it even further and using the tips provided here (specifically looking through
session_info()), I found that the local API had loaded more packages than the DigitalOcean API even though the same list of packages were set to load in both cases.In this particular case the DO API had not loaded
rmarkdown, which seems to be a required package to findpandocused when the serializerhtmlwidgetproduces a result viahtmlwidgets::saveWidget()(referenced here).So after specifically installing and loading
rmarkdownAS WELL AS setting the HOME environment variable to fix a subsequent error withpandocon Linux (referenced here), theplotlyis shown on DO as it does locally.