htmlwidgets::saveWidget Error: pandoc document conversion failed with error 97

I always use htmlwidgets::saveWidget to save my Plotly html plots in R. For some unknown reason, I started to get:

Could not find data file templates/file6efb40d38e3c.html                                        
Error: pandoc document conversion failed with error 97                                       
Execution halted   

I first thought I had some problems with the temp dir so I tried to add dir.create(tempdir()) but it wasn’t it. After some more digging I found this GitHub issue and answer from cpsievert, which solved the issue.

Instead of using file=outputdir/filename.html, what I usually use to export/save everything in R, I had to split it into file=filename.html and libdir=outputdir. The error dissapeared and I could happily save my beautiful Plotly html plots.

sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: openSUSE Leap 15.0

Matrix products: default
BLAS/LAPACK: /home/joppelt/Miniconda3/envs/riboseq/lib/libopenblasp-r0.3.10.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] htmlwidgets_1.5.3

loaded via a namespace (and not attached):
[1] compiler_3.6.3    htmltools_0.5.1.1 digest_0.6.27     rlang_0.4.10

Leave a comment