A followup after some research and discussion with TeXLive people.
This is longstanding behaviour of TeX. When you put a filename on the
command line, it does 3 things:
- If there are quotes on the filename they are stripped off.
- If you are on windows and the filename is a path starting with
something like C:\..., the backslashes are converted to forward slashes.
- The TeX macro \input is prepended, and the line
\input filename
is executed. So if filename contains special characters like tildes,
you'll try to input the name just up to the first tilde, and things
won't work.
This seems really unlikely to change, so R code that generates filenames
to send to TeX should try hard to avoid tildes. Calling normalizePath()
after the file has been created would be sufficient if the normalized
path itself doesn't contain special chars. My first workaround of
changing to the directory of the file should also work.
Duncan Murdoch
On 2025-08-10 3:22 p.m., Duncan Murdoch wrote:
I recently found out about Paul Murrell's excellent xdvir package that
renders LaTeX in a graphics device. I thought this would be useful and
put a wrapper around the latexGrob() function into rgl.
Testing it on Github workflows worked fine on Ubuntu and MacOS runners,
but failed on Windows. Here's a typical error message:
This is XeTeX, Version 3.141592653-2.6-0.999997 (TeX Live 2025) (preloaded
format=xelatex)
restricted \write18 enabled.
entering extended mode
Error: LaTeX failed to compile
C:\Users\RUNNER~1\AppData\Local\Temp\Rtmp6TD7wY/working_dir\RtmpmitpVG\file130053037941.tex.
See https://yihui.org/tinytex/r/#debugging for debugging tips.
Execution halted
(taken from
https://github.com/dmurdoch/rgl/actions/runs/16861206133/job/47761646553).
After a long series of experiments, I think I found the cause: xdvir
creates a file in tempdir(), and passes it to lualatex or xelatex (along
with various command line options). If that file contains the
"RUNNER~1" directory, which is the 8.3 form of "runneradmin", the
compile fails.
I have a workaround for this: I setwd(tempdir()) and use the basename of
the temp file.
Another workaround that I tried doesn't work: normalizePath(tempfile())
generally does nothing, because normalizePath() won't modify a path that
doesn't exist. If I write to the tempfile() and then normalize the
name, that does work.
I think there are one or more bugs here that should be fixed. I'm just
not sure what they are.
Is it a bug in TeXLive 2025, that those programs won't accept short
names? Or has Windows deprecated them, and R shouldn't be producing
them? Is it a bug that tempfile() doesn't produce a normalized path?
Duncan Murdoch
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel