Thursday, February 8, 2024

[SOLVED] Why does plotly::export() fail on Ubuntu 22.04?

Issue

This used to work on Ubuntu 20.04 but now throws an error in Ubuntu 22.04.

# plotly 4.10.4
plotly_plot <- plotly::plot_ly(data = mtcars,
                               x = ~mpg, y = ~wt,
                               type = "scatter", mode = "markers")

plotly::export(p = plotly_plot, file = "myplot.png")

Throws error:

[WARNING] Deprecated: --self-contained. use --embed-resources --standalone
Error in webshot::webshot(f, file, ...) : 
  webshot.js returned failure value: 1
In addition: Warning message:
'plotly::export' is deprecated.
Use 'orca' instead.
See help("Deprecated") 

Solution

Apparently this is related to openssl changes made between Ubuntu 20.04 and 22.04. A workaround can be achieved by doing the following:

plotly_plot <- plotly::plot_ly(data = mtcars,
                               x = ~mpg, y = ~wt,
                               type = "scatter", mode = "markers")

Sys.setenv(OPENSSL_CONF = "/dev/null")
plotly::export(p = plotly_plot, file = "myplot.png")
Sys.unsetenv("OPENSSL_CONF")


Answered By - Patrick
Answer Checked By - Mildred Charles (WPSolving Admin)