daqana/tikzDevice

Cannot open tikzStringWidthCalc.log on MacOS

Closed this issue · 7 comments

On MacOS 10.13.2 with R version 3.4.3, printing to tikz fails:

> library(ggplot2)
> library(tikzDevice)
> tikz(file="tmp.tex")
> print(ggplot(mtcars, aes(x=mpg, y=disp)) + geom_point())
Creating temporary TikZ metrics dictionary at:
	/var/folders/cd/hnjzvg453gqg224cdsy2m9x00000gn/T//RtmpbHCs7h/tikzMetricsDictionary
Using TikZ metrics dictionary at:
	/var/folders/cd/hnjzvg453gqg224cdsy2m9x00000gn/T//RtmpbHCs7h/tikzMetricsDictionary
Measuring dimensions of: \char77
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file '/var/folders/cd/hnjzvg453gqg224cdsy2m9x00000gn/T//RtmpbHCs7h/tikzDeviceccc66ce5a9a8/tikzStringWidthCalc.log': No such file or directory

It appears that the temp directory is invalid. With TMPDIR=tmp (some local directory), it still fails:

> library(ggplot2)
> library(tikzDevice)
> tikz(file="tmp.tex")
> print(ggplot(mtcars, aes(x=mpg, y=disp)) + geom_point())
Creating temporary TikZ metrics dictionary at:
	tmp/Rtmpq8QwUo/tikzMetricsDictionary
Using TikZ metrics dictionary at:
	tmp/Rtmpq8QwUo/tikzMetricsDictionary
Measuring dimensions of: \char77
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file 'tmp/Rtmpq8QwUo/tikzDevicecd524b436720/tikzStringWidthCalc.log': No such file or directory

However "tikzStringWidthCalc.tex" does exist.

Thanks. Can you please install the development version and show the output of tikzDevice::tikzTest() ?

> library(tikzDevice)
> tikzDevice::tikzTest()

Active compiler:
	pdftex
	pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017)
	kpathsea version 6.2.3

Measuring dimensions of: A
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file '/var/folders/cd/hnjzvg453gqg224cdsy2m9x00000gn/T//RtmppYt7Yj/tikzDevice30e02596d37d/tikzStringWidthCalc.log': No such file or directory

'/var/folders/cd/hnjzvg453gqg224cdsy2m9x00000gn/T//RtmppYt7Yj/tikzDevice30e02596d37d/ exists, but tikzStringWidthCalc.log does not.

Thanks. I tweaked the diagnostic code in the dev version, could you please reinstall the package and rerun?

> library(tikzDevice)
> tikzDevice::tikzTest()

Active compiler:
	pdftex
	pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017)
	kpathsea version 6.2.3

Measuring dimensions of: A
Running command: '/Users/tristan/.local/bin/luna-studio/' -interaction=batchmode -halt-on-error -output-directory '/var/folders/cd/hnjzvg453gqg224cdsy2m9x00000gn/T//RtmprPnnnk/tikzDevicea17c649ce0a9' '/var/folders/cd/hnjzvg453gqg224cdsy2m9x00000gn/T//RtmprPnnnk/tikzDevicea17c649ce0a9/tikzStringWidthCalc.tex'
Invalid option `-interaction=batchmode'

Usage:  [-f|--frontend] [-b|--backend] [-d|--develop] [-r|--force-run]
        [-a|--atom ARG]
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file '/var/folders/cd/hnjzvg453gqg224cdsy2m9x00000gn/T//RtmprPnnnk/tikzDevicea17c649ce0a9/tikzStringWidthCalc.log': No such file or directory

I'm not sure why /Users/tristan/.local/bin/luna-studio/ is picked as the pdftex command.

If I remove it from my path, then everything works well.

yihui commented

Funny... We'd better switch to tinytex someday to avoid these weird LaTeX issues: https://yihui.name/tinytex.

Thanks. This is most likely an issue with your options. I have improved tikzTest() again, could you please rerun with the latest dev version?

I figured out the issue: ENV_VAR was not checking if the environment variable was unset correctly. If the variable was unset, then the empty string was used. This causes Sys.which to return an executable if it is in the path.

I've submitted a fix (#170).