简体   繁体   中英

Paths in ssh versus Rstudio server for pandoc and knitr

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM