ssh 中的路径与 pandoc 和 knitr 的 Rstudio 服务器
Paths in ssh versus Rstudio server for pandoc and knitr
我是 运行 使用预制 AMI 的 Rstudio AWS 实例 (http://www.louisaslett.com/RStudio_AMI/)。使用这个我可以启动到 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 选项工具 -> shell 并键入
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
设置为包含 RStudio IDE/Server 附带的 pandoc
二进制文件的目录。当您调用 rmarkdown::render()
时,rmarkdown 会尝试从该环境变量中查找 pandoc
。
当然,当你运行在RStudioIDE/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 版本。
我是 运行 使用预制 AMI 的 Rstudio AWS 实例 (http://www.louisaslett.com/RStudio_AMI/)。使用这个我可以启动到 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 选项工具 -> shell 并键入
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
设置为包含 RStudio IDE/Server 附带的 pandoc
二进制文件的目录。当您调用 rmarkdown::render()
时,rmarkdown 会尝试从该环境变量中查找 pandoc
。
当然,当你运行在RStudioIDE/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 版本。