You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thank you for your work on ltx2any, it is really a handy tool for me to write Latex from vim! However, I encountered some unexpected behavior of the -t flag in combination with the -c flag.
I used it roughly like: ltx2any -t /tmp -c FILE
I thought, the temporary files would be created there and afterwards only those just created files would be deleted. However, everything in /tmp was deleted (except root's files). I think I figured out it should be used like the following: ltx2any -t /tmp/ltx2any_tmpdir -c FILE
The directory is created, the files are put there, and afterwards everything including the directory is removed -- which again is nice.
What do you think? Would it be better to clarify the behavior by making the description in parameters.rb more clear? Or is the behavior better changed? At least this can be pretty dangerous when doing ltx2any -t ~ -c ~/dir/FILE.
I was thinking of something like: Parameter.new(:tmpdir, 't', String, '"#{self[:user_jobname]}#{TMPSUFFIX}"', 'Directory for temporary files. If combined with -c, all contents of the directory including itself is removed afterwards.'),
An even safer approach might be to only accept non-existing directories as parameter (I'd prefer this).
Regards
The text was updated successfully, but these errors were encountered:
You got it exactly right: ltx2any assumes it owns the tmp directory. FWIW, whether you use -t is irrelevant: if you use the default and that directory (jobname_tmp) exists for any reason, ltx2any will usurp it completely.
FWIW, I'd happily default to mktemp -d for the temporary files -- but given that you do frequently have to consult the full log (as least I do) or do other things in the temp folder (e.g. remove PDFs created by TikZ externalization), I have rejected the idea so far.
Would it be better to clarify the behavior
Definitely. I'll check that the help output and documentation are clear about that. We definitely don't want to (accidentally) pollute an important directory with dozens of LaTeX tmp files, let alone delete it!
A related issue is that ltx2any works best if the job directory doesn't contain anything but the LaTeX project you want to build. Big files or, worse, recursive symlinks of expansive subfolders can cause trouble.
An even safer approach might be to only accept non-existing directories as parameter
That won't be helpful if you use it without-c. You want to reuse the temporary files! Outside of -d more, that's a big part of the point of the tool.
Note that storing in /tmp is not ideal in that scenario, either; we have no guarantees that the files stay around (not that it's likely, but inconsistent state might happen), and they'll most certainly be gone after a reboot.
Or is the behavior better changed?
Maybe. Here are some thoughts:
Reject any path that's outside of the working/job directory (which?).
If the tmp directory exists and wasn't created by ltx2any (marked by checking/creating a special file?), reject it.
Create a special flag that creates the temp folder in /tmp (or equivalent).
Default to a /tmp location if-c is given.
I'll think about it until 1.0. Thanks for the helpful feedback!
reitzig
changed the title
'-t' Flag with '-c' deletes more than expected
Be more careful about polluting/deleting directories specified by -t
Nov 8, 2018
Hi,
thank you for your work on ltx2any, it is really a handy tool for me to write Latex from vim! However, I encountered some unexpected behavior of the -t flag in combination with the -c flag.
I used it roughly like:
ltx2any -t /tmp -c FILE
I thought, the temporary files would be created there and afterwards only those just created files would be deleted. However, everything in
/tmp
was deleted (exceptroot
's files). I think I figured out it should be used like the following:ltx2any -t /tmp/ltx2any_tmpdir -c FILE
The directory is created, the files are put there, and afterwards everything including the directory is removed -- which again is nice.
What do you think? Would it be better to clarify the behavior by making the description in
parameters.rb
more clear? Or is the behavior better changed? At least this can be pretty dangerous when doingltx2any -t ~ -c ~/dir/FILE
.I was thinking of something like:
Parameter.new(:tmpdir, 't', String, '"#{self[:user_jobname]}#{TMPSUFFIX}"', 'Directory for temporary files. If combined with -c, all contents of the directory including itself is removed afterwards.'),
An even safer approach might be to only accept non-existing directories as parameter (I'd prefer this).
Regards
The text was updated successfully, but these errors were encountered: