4

I am running a Rstudio AWS instance using the premade AMI (http://www.louisaslett.com/RStudio_AMI/). Using this i am able to boot into rstudio server. I can create a default .Rmd file and knit without problem. I get the normal message at the end (pasted, the path may be relavent).

/usr/lib/rstudio-server/bin/pandoc/pandoc +RTS -K512m -RTS test.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output test.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /usr/local/lib/R/site-library/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /tmp/RtmpeN2em3/rmarkdown-str156c3b3566c1.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/usr/local/lib/R/site-library/rmarkdown/rmd/h/highlight 

Furthermore, i can go to shell rstudio options tools -> shell and type

Rscript -e "rmarkdown::render("test.html")"

And that knits just fine.

However, when i ssh into that same instance (git bash terminal), and try to render that same document with the same line of code. I get:

    ubuntu@ip-172-31-17-88:/home/rstudio$ Rscript -e "rmarkdown::render("test.html")"
Error: pandoc version 1.12.3 or higher is required and was not found.
Execution halted

Is there a behavior about paths in ssh that i am misunderstanding?

If i type:

pandoc
The program 'pandoc' is currently not installed. You can install it by typing:
sudo apt-get install pandoc

Then how was rstudio server able to knit to html?

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
bw4sz
  • 2,237
  • 2
  • 29
  • 53

1 Answers1

3

RStudio sets the environment variable RSTUDIO_PANDOC to the directory that contains the pandoc binaries shipped with the RStudio IDE/Server. When you call rmarkdown::render(), rmarkdown tries to find pandoc from this environment variable.

Of course, this environment variable exists when you run programs inside RStudio IDE/Server, but it is unlikely to be set outside RStudio. You either add the RStudio pandoc directory to PATH, or run everything inside RStudio.

PATH=/usr/lib/rstudio-server/bin/pandoc/:$PATH Rscript -e "rmarkdown::render("test.Rmd")"

And you can certainly install Pandoc by yourself via apt-get install, but I'm not sure if a sufficient version of Pandoc exists in your Ubuntu distribution.

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
  • 1
    One can also put `Sys.setenv(RSTUDIO_PANDOC = "/usr/lib/rstudio-server/bin/pandoc")` into e.g. .Rprofile – petermeissner Aug 22 '17 at 10:28
  • 1
    Another way would be (if you have admin rights or if your admin is willing to do it) to let `/usr/bin/pandoc` point to `/usr/lib/rstudio-server/bin/pandoc/pandoc` via e.g. `ln -symbolic /usr/bin/pandoc /usr/lib/rstudio-server/bin/pandoc/pandoc` – petermeissner Aug 23 '17 at 07:29