[英]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/ ). 我使用预制的AMI( http://www.louisaslett.com/RStudio_AMI/ )运行Rstudio AWS实例。 Using this i am able to boot into rstudio server.
使用此我可以启动到rstudio服务器。 I can create a default .Rmd file and knit without problem.
我可以创建一个默认的.Rmd文件并编织没有问题。 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 此外,我可以去shell rstudio选项工具 - > shell和类型
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. 但是,当我ssh到同一个实例(git bash终端),并尝试使用相同的代码行渲染相同的文档。 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? 在ssh中是否有关于我误解的路径的行为?
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服务器如何能够编织到HTML?
RStudio sets the environment variable RSTUDIO_PANDOC
to the directory that contains the pandoc
binaries shipped with the RStudio IDE/Server. RStudio将环境变量
RSTUDIO_PANDOC
设置为包含RStudio IDE / Server附带的pandoc
二进制文件的目录。 When you call rmarkdown::render()
, rmarkdown tries to find pandoc
from this environment variable. 当你调用
rmarkdown::render()
, rmarkdown试图从这个环境变量中找到pandoc
。
Of course, this environment variable exists when you run programs inside RStudio IDE/Server, but it is unlikely to be set outside RStudio. 当然,当您在RStudio IDE / Server中运行程序时,此环境变量存在,但不太可能在RStudio外部设置。 You either add the RStudio pandoc directory to
PATH
, or run everything inside RStudio. 您可以将RStudio pandoc目录添加到
PATH
,也可以运行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. 你当然可以通过
apt-get install
自己安装Pandoc,但我不确定你的Ubuntu发行版中是否存在足够版本的Pandoc。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.