daqana / tikzDevice

A R package for producing graphics output as PGF/TikZ code for use in TeX documents.
https://daqana.github.io/tikzDevice
132 stars 26 forks source link

Write Errors, cannot open file. #153

Closed nhamilton1980 closed 7 years ago

nhamilton1980 commented 7 years ago

I am getting write errors when using pdftex,

Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file '/var/folders/67/ys78wlfd43zc4rzmvbtfthqh0000gn/T//RtmpArEDDV/tikzStringWidthCalc.log': No such file or directory

I think it is due to the following:

Around Line 270, latexStrWidth.R

Should also have:

if(!file.exists(texLog)) file.create(texLog)

Same error does not happen when using xetex

In a local version I made the following changes, which made the error go away once the package was rebuilt and reloaded:

### LINE 266, latexStrWidth.R
texDir  <- tempdir()
texLog  <- file.path(texDir, 'tikzStringWidthCalc.log')
texFile <- file.path(texDir, 'tikzStringWidthCalc.tex')
fun     <- function(x){ if (!file.exists(x)) file.create(x); normalizePath(x,'/') }
texLog  <- fun(texLog)
texFile <- fun(texFile)

# Open the TeX file for writing.
texIn <- file(texFile, 'w')
### END MODIFICATION
yihui commented 7 years ago

Could you submit a pull request? Thanks!

krlmlr commented 7 years ago

Thanks, I don't think creating the .tex and .log files is necessary. Please open a new issue if the problem persists.