pandoc error with RStudio, knit to html, and plotly

I am getting a pandoc error when using the latest preview RStudio to knit to html when there is a plotly graphic included. I'm using pandoc version 2.2.1 and R version information is below, along with the error message. pandoc somehow thinks that a file is a directory.

Here is testit.Rmd:

title: "testit"
author: "FE Harrell"
date: "September 11, 2016"
output: html_document
A sentence

plot_ly(x=1:4, y=runif(4))

A concluding sentence

Session info and error message:

R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 19.04

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/

 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8  
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            

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

other attached packages:
[1] plotly_4.8.0  ggplot2_3.1.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0        pillar_1.3.1      compiler_3.6.0    plyr_1.8.4        bindr_0.1.1       tools_3.6.0       digest_0.6.18     viridisLite_0.3.0
 [9] jsonlite_1.6      evaluate_0.13     tibble_2.0.1      gtable_0.2.0      pkgconfig_2.0.2   rlang_0.3.1       rstudioapi_0.10   yaml_2.2.0      
[17] xfun_0.6          bindrcpp_0.2.2    withr_2.1.2       dplyr_0.7.8       httr_1.4.0        knitr_1.21        htmlwidgets_1.3   grid_3.6.0      
[25] tidyselect_0.2.5  glue_1.3.0        data.table_1.12.0 R6_2.4.0          rmarkdown_1.11    tidyr_0.8.2       purrr_0.3.0       magrittr_1.5    
[33] scales_1.0.0      htmltools_0.3.6   assertthat_0.2.0  colorspace_1.4-0  lazyeval_0.2.1    munsell_0.5.0     crayon_1.3.4    


Error message when doing "knit to html" in Rstudio:

/usr/lib/rstudio/bin/pandoc/pandoc +RTS -K512m -RTS --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output testit.html --email-obfuscation none --self-contained --standalone --section-divs --template /usr/lib/R/site-library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:bootstrap' --include-in-header /tmp/RtmpTglYwo/rmarkdown-str17a24d9a78f2.html --mathjax --variable 'mathjax-url:'
output file:

pandoc: /usr/lib/R/site-library/plotly/htmlwidgets/lib/typedarray/typedarray.min.js: openBinaryFile: inappropriate type (is a directory)
Error: pandoc document conversion failed with error 1
Execution halted
1 Like

I do not know if it was an error of your question or if indeed the testit.Rmd code is incomplete, since the chunck of the R code is incomplete. You put:

title: "testit"
author: "FE Harrell"
date: "September 11, 2016"
output: html_document
A sentence

plot_ly(x=1:4, y=runif(4))

Note that the chunck term ``` was omitted in the example. This causes me doubts, although I believe that this does not cause problems, since there is nothing else ahead of the chunk.

On my machine compiled correctly. Here I have installed a version of rmardkwon from GitHub:

rmarkdown     1.13.3  2019-06-13 [1] Github (rstudio/rmarkdown@d1b9935)

Note: I'm using pandoc 2.7.2-55.

Best regards,

Sorry about that. My test file did have the terminating triple backquote, so that's not the issue.

I've very confused about pandoc versions. reports that latest versions are in debian/ubuntu/etc. servers but apt-get install pandoc gets me version 2.2.1. Manually downloading and dpkg -i installing pandoc gets me version 2.7.3. But I found pandoc also in /usr/lib/rstudio/bin at version 2.3.1. But the Rmarkdown/knitr error message says its using /usr/bin/pandoc.

Any help working through this much appreciatged.

I also can't reproduce the error.

I'm using current CRAN versions of rmarkdown, plotly, and knitr, which are all slightly ahead of what you have. Have you tried updating those? I'm also using pandoc version 2.7.1.

What do you get when you run rmarkdown::pandoc_version() in your Console? That could potentially help you figure out which of your versions R is using. Based on the documentation it sounds like R should be using the newest version it finds:

The system environment variable PATH as well as the version of pandoc shipped with RStudio (its location is set via the environment variable RSTUDIO_PANDOC by RStudio products like the RStudio IDE, RStudio Server, Shiny Server, and RStudio Connect, etc) are scanned for pandoc and the highest version available is used. Please do not modify the environment variable RSTUDIO_PANDOC unless you know what it means.

1 Like

Thanks for this. pandoc_version() returns 2.7.3 and /usr/bin/pandoc --version returns the same.

The versions of rmarkdown, plotly, knitr could be a problem but I'm committed to the debian/Ubuntu way of updating R packages, e.g., sudo apt-get install r-cran-knitr because some of the frequently updated packages are slow to compile from tarballs. It's too bad that the debian repo is not quite as up to date as CRAN. I wish I knew how to find a more up-to-date debian repo for this.

Which version of RStudio are you using, if that matters?

Another other suggestions welcomed.

1 Like

I'm using a preview version RStudio (1.2.1541). I'm pretty sure I just updated it this week :grin:, but I see today that the current preview version is 1.2.1555. I'll see if anything changes if I update that but otherwise I'm out of ideas. Hopefully someone else will come along with a bright idea for you!


@harrelfe Are you using the cran2deb4ubuntu PPA? It provides up-to-date versions of many CRAN packages for Ubuntu. For example, I have the latest versions of knitr, rmarkdown, and plotly installed as Debian binaries:

$ apt list --all-versions --installed r-cran-knitr r-cran-rmarkdown r-cran-plotly
Listing... Done
r-cran-knitr/bionic,bionic,now 1.23-1cran1ppabionic0 all [installed]
r-cran-knitr/bionic 1.17-2 all

r-cran-plotly/bionic,bionic,now 4.9.0-1cran1ppabionic0 all [installed]
r-cran-plotly/bionic,bionic 4.7.1+dfsg-1 all

r-cran-rmarkdown/bionic,bionic,now 1.13-1cran1ppabionic0 all [installed]

Note that the default non-PPA packages are a few versions behind.

I was so glad to learn from you how to get a more up-to-date debian repo for R packages. By going to and running the commands given there, I hit some problems though:

sudo add-apt-repository ppa:marutter/rrutter
Err:9 disco Release           
  404  Not Found [IP: 80]
Hit:8 jessie InRelease
Reading package lists... Done
E: The repository ' disco Release' does not have a Release file.

and similar for sudo add-apt-repository ppa:marutter/c2d4u

If it matters, I have the following at the bottom of /etc/apt/sources.list:
deb disco-cran35/

Any ideas?

1 Like

@harrelfe Try adding the following to /etc/apt/sources.list:

deb disco main

If that doesn't work, try changing disco to bionic. I recall at some point the maintainer (Michael Rutter) started targeting only the LTS releases, but they should work regardless (I did this back when I was running Ubuntu 17.10).

Also, there is no need to add the PPA marutter/rrutter. It is identical to the entry you already have (Michael copies his personal rrutter PPA to the official CRAN Ubuntu repo).

1 Like

Sorry to bother you again. Looks like that may work with bionic (but not disco or cosmic) but I get a "no public key available" error message. Know offhand how to define a key for this PPA site?

1 Like

@harrelfe I don't think the PPA requires a key.

One point of confusion is that the link I had sent you is somewhat outdated. Due to the changes introduced in the 3.5 release of R, the maintainers had to create a new PPA, c2d4u3.5, which is explained in this blog post.

The rocker project has successfully created Dockerfiles for all the recent Ubuntu releases using this PPA strategy. The image is called r-apt. Here is the relevant line:

add-apt-repository --enable-source --yes "ppa:marutter/c2d4u3.5" 

Note that they also use ppa:marutter/rrutter3.5 in this Dockerfile, but again that is identical to the main source from CRAN, which you've already setup.

I ran a r-apt disco container (rocker/r-apt:disco) to confirm that you should currently list bionic for any distribution post 18.04:

$ cat /etc/apt/sources.list.d/marutter-ubuntu-c2d4u3_5-bionic.list 
deb bionic main
deb-src bionic main
1 Like

You have been incredibly helpful. Thank you! This allowed many R packages to be updated and the original problem with plotly/rmarkdown/knitr/pandoc is fixed!

Here's what I did:

Add to /etc/apt/sources.list:
deb bionic main
deb-src bionic main

gpg --keyserver --recv-key C9A7585B49D51698710F3A115E25F516B04C661B
gpg -a --export C9A7585B49D51698710F3A115E25F516B04C661B | sudo apt-key add -
sudo apt-get update
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.