My texi2dvi
is apparently in a place where R CMD Rd2pdf
doesn't expect it. Mine is at /usr/local/bin/texi2dvi
, and it's being looked for at /usr/local/opt/texinfo/bin/texi2dvi
:
[KenMacBook:~/git] % \R CMD Rd2pdf missing
Hmm ... looks like a package
Converting Rd files to LaTeX
Creating pdf output from LaTeX ...
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'Rd2.tex' failed.
Messages:
sh: /usr/local/opt/texinfo/bin/texi2dvi: No such file or directory
Output:
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'Rd2.tex' failed.
Messages:
sh: /usr/local/opt/texinfo/bin/texi2dvi: No such file or directory
Output:
Error in running tools::texi2pdf()
I can work around this by running R_TEXI2DVICMD=/usr/local/bin/texi2dvi R CMD Rd2pdf
, and then the docs are built correctly.
I'd like to put that setting in my .Rprofile
so that things like RStudio (which won't read my .zshrc
) and other random R sessions will see the setting. But neither of the following seems to have any effect in my .Rprofile
:
Sys.setenv(R_TEXI2DVICMD='/usr/local/bin/texi2dvi')
options(texi2dvi='/usr/local/bin/texi2dvi')
I'm guessing .Rprofile
doesn't get read by R CMD
commands, is that correct? Is there an appropriate place to put my settings?
UPDATE:
Since Dirk doubts my doubting of .RProfile
for affecting R CMD Rd2pdf
:-), here's my evidence:
[KenMacBook:~/git] % tail -n2 ~/.Rprofile
Sys.setenv(TEXI2DVI='/no/where')
cat("End of RProfile\n")
[KenMacBook:~/git] % Rscript -e '2+2'
End of RProfile
[1] 4
[KenMacBook:~/git] % R CMD Rd2pdf missing
Hmm ... looks like a package
Converting Rd files to LaTeX
Creating pdf output from LaTeX ...
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'Rd2.tex' failed.
Messages:
sh: /usr/local/opt/texinfo/bin/texi2dvi: No such file or directory
Output:
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'Rd2.tex' failed.
Messages:
sh: /usr/local/opt/texinfo/bin/texi2dvi: No such file or directory
Output:
Error in running tools::texi2pdf()
Notice that the file's settings are respected in a normal R session, but setting TEXI2DVI
has no effect here.
The back-and-forth with Dirk produced some solutions, but they're pretty buried, so I summarize them here.
Diagnosis:
etc/Renviron
contains stale info.My
/usr/local/Cellar/r/3.2.2_1/R.framework/Versions/3.2/Resources/etc/Renviron
file (installed using Homebrew) contains this line:That's a remnant of someone (possibly me, possibly Homebrew's R package creator) who installed MacTeX in the default location, and then that path got frozen in time in the
Renviron
file. Mytexi2dvi
is now at/usr/local/bin/texi2dvi
, so this value needs to be overridden somehow.1)
$HOME/.Rprofile
and$HOME/.Renviron
won't help.They don't take effect soon enough for R to notice them. R sets
options("texi2dvi")
based on the environment it sees at startup,See "Initialization at Start of an R Session" for more info about startup files, though as shown above, the information in that document about overriding
R_HOME/etc/Renviron
is either incorrect or incomplete for this situation. Perhaps it should be amended in the section aboutR_CHECK_ENVIRON
andR_BUILD_ENVIRON
to also include something aboutR CMD RD2*
, but I'm not sure whether that's what's going on, I only know this isn't a solution.2)
$HOME/.zshrc
(and friends) won't help.On OS X, your shell startup file is not consulted when you launch GUI apps. You could use
defaults write
orlaunchctl setenv
to change theTEXI2DVI
variable so that it's set when R launches, but you'd also have to stick it in your shell startup file for processes not started bylaunchd
, which is icky. I also version my dotfiles, and I don't like sticking this bit of configuration in thelaunchctl
ether where I can't easily remember it's there. Butlaunchctl
is presumably one solution to this.3)
etc/Renviron.site
won't help.This one is surprising - I expected it to work:
So
Renviron.site
's settings aren't taking effect here. I'm getting impatient, so I didn't try to diagnose why.3) Editing
etc/Renviron
as a last resortSo this finally works:
I don't like it much, because I'll lose those settings next time I upgrade R. And R's documentation specifically says "do not change ‘R_HOME/etc/Renviron’ itself". But at least it works.