lualatex / luamplib

generic TeX package - including MetaPost code in LuaTeX documents
http://ctan.org/pkg/luamplib
14 stars 11 forks source link

luamplib creates unexpected files #106

Open Reissner opened 1 year ago

Reissner commented 1 year ago

I compile the following file test.tex

\documentclass{article}
\usepackage{fontspec}
\usepackage{luamplib}

\begin{document}

\begin{mplibcode}
input metauml;
beginfig(1);
  Note.xxx("Hello");
  drawObjects(xxx);
  endfig;
  end
bye
\end{mplibcode}
\end{document}

with lualatex -recorder test. The problem occurs also with no recorder option. What I face are a lot of files in the local folder all of the form luamplib_input_metauml*_mp but all empty.

When I open test.fls then I observe lines like the following:

INPUT /usr/share/texmf/metapost/metauml/metauml.mp
OUTPUT                 ./luamplib_input_metauml_mp
...
INPUT /usr/share/texmf/metapost/metauml/util_object.mp
OUTPUT                 ./luamplib_input_util_object_mp

This seems part of the explanation: lualatex seems to load several files tied with metauml but no idea why it writes those mysterious files.

Some hint is in the luamplib documentation: from the documentation

local function replaceinputmpfile (name,file)
167 local ofmodify = lfsattributes(file,”modification”)
168 if not ofmodify then return file end
169 local cachedir = luamplib.cachedir or outputdir
170 local newfile = name:gsub(”%W”,”_”)
171 newfile = cachedir ..”/luamplib_input_”..newfile   <-----------
172 if newfile and luamplibtime then
173 local nf = lfsattributes(newfile)
174 if nf and nf.mode == ”file” and
175 ofmodify == nf.modification and luamplibtime < nf.access then
176 return nf.size == 0 and file or newfile
177 end
178 end

I think this could be lua... can anyone tell me what happens here and how can I avoid these files in the local directory?

Thanks in advance.

dohyunkim commented 1 year ago

That is intentional, though it may be a suboptimal solution. The luatex manual says in section 11.2.1:

An etex has to be followed by a space or ; or be at the end of a line 
and preceded by a space or at the beginning of a line.

and this is not always consistent with the coding usage of .mp file.

What is surprising to me is that the temporary files are stored in the local directory. Would you please tell me the result of this command?

kpsewhich --expand-var '$TEXMFVAR'
Reissner commented 1 year ago

In my case, kpsewhich --expand-var '$TEXMFVAR' yields /var/lib/texmf.

I had also the impression from the lua(?) code that the files are intended to go into some hidden folder.

I do not understand what my question has to do with your hint on etex and related.

dohyunkim commented 1 year ago

In my case, kpsewhich --expand-var '$TEXMFVAR' yields /var/lib/texmf.

Then the temporary files should go into /var/lib/texmf/luamplib_cache/. I guess that you do not have write permission on the TEXMFVAR directory. As a workaround, you can redefine cache directory in the luamplib.cfg or in your tex file:

\mplibcachedir{/whatever/you/have/write/access}

I do not understand what my question has to do with your hint on etex and related.

For instance, the example code of Figure 5 in mpboxes.pdf (texdoc mpboxes) compiles well with mpost, but raises error with lualatex.

Reissner commented 1 year ago

Hm, so, lualatex is not really a full reimplementation of mpost?