使用LaunchControl运行.Rnw脚本时出现texi2dvi()错误 [英] texi2dvi() error when running a .Rnw script with LaunchControl

查看:271
本文介绍了使用LaunchControl运行.Rnw脚本时出现texi2dvi()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 LaunchControl 在计时器上编译编织脚本.启动了用于在OSX上计划类似cron的作业的GUI).

I'm trying to compile a knitr script on a timer using LaunchControl (a launchd GUI for scheduling cron-like jobs on OSX).

我有一个执行此任务的dispatcher.R脚本:

I have a dispatcher.R script that does this:

#!/Library/Frameworks/R.framework/Resources/Rscript
library("knitr")
setwd("~/somedirectory")
knit2pdf("my_script.Rnw", output= "my_script.tex")

当我在RStudio中以交互方式运行它时,my_script.Rnw效果很好.我得到所需的PDF输出.但是,启动时运行dispatcher.R脚本,会出现此错误:

When I run it interactively from in RStudio, my_script.Rnw works great. I get the desired PDF output. However, when launchd runs the dispatcher.R script I get this error:

texi2dvi中的错误(file = file,pdf = TRUE,clean = clean,quiet = quiet,: 在"my_script.tex"上运行"texi2dvi"失败. 执行停止

Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, : Running 'texi2dvi' on 'my_script.tex' failed. Execution halted

.tex文件已生成,但随后未编译.我会说这是我的LaTeX安装路径的问题,但是由于它可以使用knit2pdf()起作用,所以我不确定.可能是什么问题?

The .tex file gets generated, but then it doesn't compile. I a would say it was problem with my LaTeX installation path, but since it works using knit2pdf() I'm not sure. What could be the issue?

仍在努力.更新:

  • 没有任何日志文件通过LaunchControl用knit2pdf()生成,但是我得到了.tex文件和/figure文件夹.

  • No .log file gets produced with knit2pdf() via LaunchControl, but I get a .tex file and /figure folder.

我更新了MacTex,还尝试了一个空文档的最小示例,但我得到了有关texi2dvi的相同错误.

I updated MacTex and also tried a minimal example of an empty document and I got the same error about texi2dvi.

推荐答案

要使用LaunchControl运行.Rnw文件进行任务调度,请在同一目录中创建以下文件.然后,在调度程序中运行* .sh脚本.瞧!我在原始帖子中遇到的问题是LaunchControl不(至少默认情况下)不读取〜/.bash_profile,因此将PATH变量添加到.sh脚本即可解决此问题.

To run a .Rnw file using LaunchControl for task scheduling, create the following files in the same directory. Then, run the *.sh script in the scheduler. Voila! The problem I was encountering in my original post was the LaunchControl doesn't (by default, at least) read ~/.bash_profile, so adding the PATH variable into the .sh script resolves this.

这是您可以编译而不会从RStudio发出任何问题的任何knitr脚本.

This is any knitr script that you can compile without issue from RStudio.

#!/Library/Frameworks/R.framework/Resources/Rscript
library("knitr")
setwd("~/some_directory")
knit2pdf("yourscript.Rnw", output = "yourscript.tex")

3)一个* .sh脚本

确保您具有LaTeX安装的PATH变量.

3) A *.sh script

Make sure that you have the PATH variable to your LaTeX installation.

#! /bin/bash 

PATH="/usr/texbin:${PATH}"
export PATH

Rscript yourscript_dispatcher.R

此解决方案适用于R版本3.3.2(2016-10-31)的OSX Yosemite 10.10.5.

This solution works on OSX Yosemite 10.10.5 on R version 3.3.2 (2016-10-31).

这篇关于使用LaunchControl运行.Rnw脚本时出现texi2dvi()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆