Bug in running external program (-shell-escape)
Mario D
egalua at gmail.com
Sat Mar 4 12:58:51 UTC 2023
Jurgen,
maybe I didn't explain myself correctly.
My setting is as follows: I have my file test.lyx in my current dir, let's
say $HOME/test
It uses the library "external" with option
\tikzexternalize[prefix=picts/]
The directory "$HOME/test/picts" DOES already exist (in my current working
directory $HOME/test).
What I (the user) would expect to happen is that when I compile with Lyx
then the files
test-figure0.dpth
test-figure0.log
test-figure0.md5
test-figure0.pdf
get created in "$HOME/test/picts"
This is, actually, what just happens if I export test.lyx to test.tex and
then I compile it with
pdflatex -shell-escape test.tex
and this is what should happen (I think) also in Lyx, whereas when
compiling in Lyx I get the message that the file cannot be created in the
(already existing) directory.
That's it.
What happens in the temporary lyx directory is another story which, in my
opinion, should be transparent to the end user.
I reported it because it was pointed out by Paul and maybe it could help to
understand what is going on.
Re the other points you make in this and the following message:
1) yes, running without prefix is a workaround but
a) I apply this settings to files with hundreds of pictures, so the
current dir gets messed up and this is not nice;
b) it doesn't look good to me to have a feature that doesn't work as it is
intended in latex;
c) in any case, picture files are not created at all anywhere (I guess
they live just in RAM), which is not the intended use of the external
library;
2) yes, if I use
\usepackage{shellesc}
\ShellEscape{mkdir picts}
then Lyx can create the dir but this happens in the temporary dir, not in
my current workind dir (where, btw, the dir "picts" already exists) and the
file compiles without error.
Note that this, anyway, happens in the temporary directory, which gets
deleted when you close Lyx, so the next time you open it, the whole thing
starts afresh: the first time you compile the file, it has to process all
the figures. This:
a) again, is not the intended use of the external library;
b) is a bit annoying with a file of many tens, even hundreds, of figures
that can take many minutes to compile each first time you open it;
3) the tmp dir has a dynamic name, so creating a symlink from there to
"$HOME/test/picts" would not be feasible in a permanent way but should be
done every time you start lyx and open your file, and this is quite
annoying.
All in all, it seems to me that there is a problem in the implementation of
the external library in lyx: it writes the figure files (*.dpth, *.log,
*.md5, *.pdf) assuming as root dir the document temp dir, something like
/tmp/lyx_tmpdir.dJCMQsEYwFBx/lyx_tmpbuf0/
whereas, in my opinion, it should use as root dir the dir the file lives in.
Please note that even providing the absolute path to external doesn't help:
Lyx always tries to use as root the temp directory.
I hope to have explained myself a little bit better.
Thanks
Mario
Il giorno sab 4 mar 2023 alle ore 09:25 Jürgen Spitzmüller <
jspitzm at gmail.com> ha scritto:
> Am Freitag, dem 24.02.2023 um 11:56 +0100 schrieb Mario D:
> > It looks like I have found a bug using the external library in lyx:
> > if you pass the option
> > \tikzexternalize[prefix=some_dir/]
> > then lyx is not able to create the subdir "some_dir" in its temporary
> > working dir under the /tmp tree, which results in a compilation error
> > since lyx is not able to write the necessary files.
>
> It's not really that LyX cannot create the subdir. The problem is that
> this subdir must exist beforehand (you get the same error when running
> pdflatex --shell-escape manually without having manually created this
> subdir before that).
>
> I agree that LyX could do this, but then, such subdirs in the temporary
> directory do not make much sense really, so running without prefix
> seems like a feasible workaround.
>
> If you really want to have this subdir for some reason, you need to
> include a routine that creates it. Since you have --shell-escape
> enabled anyway, the most simple solution would be:
>
> \usepackage{shellesc}
> \ShellEscape{mkdir picts}
>
> HTH,
> --
> Jürgen
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20230304/9536ad7a/attachment-0001.html>
More information about the lyx-devel
mailing list