我正在使用预制的 AMI (http://www.louisaslett.com/RStudio_AMI/) 运行 Rstudio AWS 实例。使用它我可以启动到 rstudio 服务器。我可以创建一个默认的 .Rmd 文件并毫无问题地编织。我在最后收到正常消息(已粘贴,路径可能是相关的)。

/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  

此外,我可以去 shell rstudio options tools -> shell and type
Rscript -e "rmarkdown::render("test.html")" 

而且编织得很好。

但是,当我 ssh 进入同一个实例(git bash 终端)并尝试使用同一行代码呈现同一个文档时。我得到:
    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 

我误解了 ssh 中的路径行为吗?

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

那么rstudio服务器是如何编织成html的呢?

请您参考如下方法:

RStudio 设置环境变量 RSTUDIO_PANDOC到包含 pandoc 的目录RStudio IDE/Server 附带的二进制文件。当您调用 rmarkdown::render() , Markdown 试图找到 pandoc从这个环境变量。

当然,当你在 RStudio IDE/Server 中运行程序时,这个环境变量是存在的,但不太可能在 RStudio 之外设置。您可以将 RStudio pandoc 目录添加到 PATH ,或在 RStudio 中运行所有内容。

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

您当然可以通过 apt-get install 自己安装 Pandoc ,但我不确定您的 Ubuntu 发行版中是否存在足够版本的 Pandoc。


评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!