James-Yu / LaTeX-Workshop

Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
MIT License
10.55k stars 522 forks source link

Not cleaning custom outDir #4188

Closed memeplex closed 6 months ago

memeplex commented 6 months ago

Pre-checks*

Please change the following [ ] to [x] for confirmation.

  • [x] The issue has not been reported in this repository.
  • [x] The issue remains after disabling all other extensions and restarting Visual Studio Code.
  • [x] The FAQ cannot address the issue.
  • [x] The issue is not related to compiling a document, or the document can be successfully compiled in the OS terminal but not in Visual Studio Code with this extension.

Environment*

Please write exact version numbers instead of descriptors such as latest.

  • Operating System: macOS Sonoma 14.3.1
  • Visual Studio Code Version: 1.87.0
  • LaTeX Workshop Version: 9.18.2
  • TeX Distribution Version: basictex 2023.0314

The Issue*

I've set latex-workshop.latex.outDir to "/tmp/latex-out". I built a simple document from LaTeX Workshop using the default latexmk recipe without any issue, the output and auxiliary files are in /tmp/latex-out. But the Clean up auxiliary files command does nothing, although it works for the default latex-workshop.latex.outDir setting.

I've also tried enabling latex-workshop.latex.clean.subfolder.enabled since it's documented that:

Clean LaTeX auxiliary files recursively in sub-folders of latex-workshop.latex.outDir

but to no avail. Moreover, the value of latex-workshop.latex.clean.method is the default "glob", which:

Clean all the files located in latex-workshop.latex.outDir [...]

Perhaps I'm missing something, but I believe this should be working.

Reproduction Steps

  1. Open empty folder
  2. Create simple template document
  3. Change latex-workshop.latex.outDir to some directory
  4. Build the project
  5. Check that the files are in the out dir.
  6. Clean up the project
  7. Check that the files still are there

Expected Behavior

Auxiliary files are removed from outDir.

Logs

LaTeX Workshop Output*

Please paste the whole log messages below, not parts of ones. The log should start with New log placeholder %WS1% registered.

[Paste the log here. Do not remove the surrounding backquotes (`).]

Developer Tools Console

Please paste the whole log messages below, not parts of ones. This console logs can sometimes be very important in many cases. To access the log, click Help -> Toggle Developer Tools -> Console.


[18:42:25.086][Logger] New log placeholder %WS1% registered for /private/tmp/lwp .
[18:42:25.086][Extension] Initializing LaTeX Workshop.
[18:42:25.321][Build][Recipe] Set $LATEXWORKSHOP_DOCKER_LATEX: ""
[18:42:25.439][Server] Creating LaTeX Workshop http and websocket server.
[18:42:25.593][Format][Bib] Bibtex format config: {"tab":"  ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]}
[18:42:25.678][Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":55536} .
[18:42:25.679][Extension] Extension root: /Users/carlos/.vscode/extensions/james-yu.latex-workshop-9.18.2
[18:42:25.679][Extension] $PATH: /Users/carlos/Documents/Util:/Users/carlos/.local/bin:/Users/carlos/.venvs/base/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/TeX/texbin
[18:42:25.680][Extension] $SHELL: /opt/homebrew/bin/bash
[18:42:25.680][Extension] $LANG: en_US.UTF-8
[18:42:25.680][Extension] $LC_ALL: en_US.UTF-8
[18:42:25.680][Extension] process.platform: darwin
[18:42:25.680][Extension] process.arch: arm64
[18:42:25.680][Extension] vscode.env.appName: Visual Studio Code
[18:42:25.680][Extension] vscode.env.remoteName: undefined
[18:42:25.681][Extension] vscode.env.uiKind: 1
[18:42:25.686][Config] latex-workshop.latex.outDir: "/tmp/latex-out" .
[18:42:25.818][Extension] Trigger characters for intellisense of LaTeX documents: ["\\",",","{"]
[18:42:25.820][Root] Current workspace folders: ["file://%WS1%"]
[18:42:25.840][Extension] LaTeX Workshop initialized.
[18:42:25.841][Root] Found root file from active editor: %WS1%/test.tex
[18:42:25.842][Root] Root file changed: from %WS1%/test.tex to %WS1%/test.tex, langID latex . Refresh dependencies
[18:42:25.842][Event] ROOT_FILE_CHANGED: "%WS1%/test.tex"
[18:42:25.842][Cacher][Watcher] Reset.
[18:42:25.842][Cacher][Watcher] Reset.
[18:42:25.843][Cacher][Watcher] Reset.
[18:42:25.847][Cacher] Adding %WS1%/test.tex .
[18:42:25.847][Cacher][Watcher] Watched %WS1%/test.tex with a new watcher on %WS1% .
[18:42:25.847][Event] FILE_WATCHED: "%WS1%/test.tex"
[18:42:25.849][Cacher] Caching %WS1%/test.tex .
[18:42:25.850][Cacher] Updated inputs of %WS1%/test.tex .
[18:42:25.850][Cacher] Parse LaTeX AST: %WS1%/test.tex .
[18:42:25.850][Event] ROOT_FILE_SEARCHED
[18:42:25.906][Cacher] Parsed LaTeX AST: %WS1%/test.tex .
[18:42:25.906][File] Calling kpsewhich to resolve article.cls .
[18:42:25.930][Cacher] Updated elements in 24.27 ms: %WS1%/test.tex .
[18:42:25.931][Event] FILE_PARSED: "%WS1%/test.tex"
[18:42:25.932][Cacher] Parsing .fls /tmp/latex-out/test.fls .
[18:42:25.967][Cacher] Found .aux %WS1%/test.tex from .fls /tmp/latex-out/test.fls , parsing.
[18:42:25.968][Cacher] Parsed .aux %WS1%/test.tex .
[18:42:25.968][Cacher] Parsed .fls /tmp/latex-out/test.fls .
[18:42:25.969][Structure] Structure force updated with 0 root sections for %WS1%/test.tex .
[18:42:25.969][Event] STRUCTURE_UPDATED
[18:42:25.983][Server] valdOrigin is http://127.0.0.1:55536
[18:42:36.822][Commander] BUILD command invoked.
[18:42:36.822][Build] The document of the active editor: file://%WS1%/test.tex
[18:42:36.822][Build] The languageId of the document: latex
[18:42:36.822][Root] Current workspace folders: ["file://%WS1%"]
[18:42:36.823][Root] Found root file from active editor: %WS1%/test.tex
[18:42:36.823][Root] Keep using the same root file: %WS1%/test.tex
[18:42:36.823][Event] ROOT_FILE_SEARCHED
[18:42:36.824][Event] STRUCTURE_UPDATED
[18:42:36.824][Build] Building root file: %WS1%/test.tex
[18:42:36.824][Build][Recipe] Build root file %WS1%/test.tex
[18:42:36.826][Build][Recipe] Preparing to run recipe: latexmk.
[18:42:36.826][Build][Recipe] Prepared 1 tools.
[18:42:36.841][Build][Recipe] outDir: /tmp/latex-out .
[18:42:36.842][Build] Recipe step 1 The command is latexmk:["-synctex=1","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=/tmp/latex-out","%WS1%/test"].
[18:42:36.842][Build] env: {}
[18:42:36.842][Build] root: %WS1%/test.tex
[18:42:36.843][Build] cwd: %WS1%
[18:42:36.845][Build] LaTeX build process spawned with PID 65684.
[18:42:37.905][Parser][TexLog] Logged 0 messages.
[18:42:37.905][Build] Finished a step in recipe with PID 65684.
[18:42:37.905][Build] Successfully built %WS1%/test.tex .
[18:42:37.905][Event] BUILD_DONE
[18:42:37.906][Viewer] Call refreshExistingViewer: "/tmp/latex-out/test.pdf" .
[18:42:37.906][Viewer] Not found PDF viewers to refresh: /tmp/latex-out/test.pdf
[18:42:37.906][Cacher] Parsing .fls /tmp/latex-out/test.fls .
[18:42:37.911][Cacher] Found .aux %WS1%/test.tex from .fls /tmp/latex-out/test.fls , parsing.
[18:42:37.911][Cacher] Parsed .aux %WS1%/test.tex .
[18:42:37.911][Cacher] Parsed .fls /tmp/latex-out/test.fls .
[18:42:47.860][Commander] CLEAN command invoked.
[18:42:47.860][Root] Current workspace folders: ["file://%WS1%"]
[18:42:47.861][Root] Found root file from active editor: %WS1%/test.tex
[18:42:47.861][Root] Keep using the same root file: %WS1%/test.tex
[18:42:47.861][Event] ROOT_FILE_SEARCHED
[18:42:47.861][Event] STRUCTURE_UPDATED
[18:42:47.862][Cleaner] Clean temporary files command The command is latexmk:["-c","%WS1%/test.tex"].
[18:42:48.032][Commander] CLEAN command invoked.
[18:42:48.033][Root] Current workspace folders: ["file://%WS1%"]
[18:42:48.033][Root] Found root file from active editor: %WS1%/test.tex
[18:42:48.033][Root] Keep using the same root file: %WS1%/test.tex
[18:42:48.033][Event] ROOT_FILE_SEARCHED
[18:42:48.033][Event] STRUCTURE_UPDATED
[18:42:48.033][Cleaner] Clean temporary files command The command is latexmk:["-c","%WS1%/test.tex"].
James-Yu commented 6 months ago

[18:42:47.862][Cleaner] Clean temporary files command The command is latexmk:["-c","%WS1%/test.tex"].

Method is not set to glob.

memeplex commented 6 months ago

Right. But then there is a documentation issue, because in two places glob is documented as the default for latex-workshop.latex.clean.method as I mentioned above.

image image

But:

image
memeplex commented 6 months ago

Moreover, even if method is not set to glob as documented, there are another misleading parts of the documentation:

image image

In no part it is stated that this functionality depends on the clean method.

jlelong commented 6 months ago

I will fix the wiki shortly.

Going back to the original problem, latexmk -c must be called with the option -outdir otherwise it cannot find the .fdb_latexmk which contains all the information generated by latexmk.

memeplex commented 6 months ago

latexmk -c must be called with the option -outdir

Yes, I'd thought about this and agree. Anyway, since the command is configurable it's better to be aware that you may break things if you change it. But as a default value using -outdir would be more consistent with the documented behavior and other settings of LW. Thanks!

kaba2 commented 5 months ago

The Clean command doesn't seem to work for me either (in 9.19.1). I'm not sure whether I have understood correctly, but I consider .aux, .blg, .fdb_latexmk, .fls, .idx, .ilg, .ind, .log, .out, .run.xml, .synctex, .synctex.gz all temporary files. But they are left untouched:

image

image

My document consists of a subfiles-tree, could that make a difference?

memeplex commented 5 months ago

Those seem to be files for separate compilations of specific files like appendix and boundary, not for dimension-paper which is the target of the clean command.

I'm not sure but I don't think it should be removing them.

kaba2 commented 5 months ago

The dimension-paper.tex references appendix.tex and others by subfiles like this:

image

The build of dimension-paper.tex triggers the build of all files recursively. So it is then natural to expect that Clean reverts the Build; i.e. removes all temporary files of all subfiles recursively.

memeplex commented 5 months ago

I don't use subfiles myself but my understanding (and a little test I did) is that it doesn't trigger separate compilations when you compile the main file (and I don't think that those separate compilations would make sense given how TeX works). See also the answer to question 3 here. Are you sure that you haven't separately compiled appendix.tex?

kaba2 commented 5 months ago

I deleted all temporarily files manually, and then rebuilt the root file dimension-paper.tex. You are right that it only generates temporary files for dimension-paper.tex.

The point of using subfiles is to chop down a long paper/book into manageable pieces which I can edit in isolation, to avoid long build times for previews when I modify something. So my writing consists of jumping to a specific subfile, and making many modify-build cycles for it. That generates the temporary files for the subfile. Logically everything under the subfile tree rooted under the root file is in the same project, so I would like to be able to clean all files in that "project".

memeplex commented 5 months ago

I created this simple project:

test.tex
========

\documentclass{article}
\usepackage{subfiles}

\begin{document}
Pre
\subfile{subfile}
Post
\end{document}
subfile.tex
===========

\documentclass[test.tex]{subfiles}

\begin{document}
Inside
\end{document}

I built both files separately, so I now have aux files for both.

If I run clean when subfile.tex is active, I get these options:

image

The second one will remove the aux files for subfile.tex

I think that behavior is ok, but I understand that sometimes you would like to say "delete everything from this project". You could easily customize this with latex-workshop.latex.clean.method/command/args or add a new task for that.

memeplex commented 5 months ago

Moreover, if you're generating a ton of aux files from many different subfiles, it could be saner to just set a different outdir.

kaba2 commented 5 months ago

The situations where I'd need to Clean Everything are where seemingly the build process gets somehow stuck or confused, and it is not clear why (e.g. renaming subfiles may lead to something like this). In these situations I just do the nuclear option of deleting everything in the output directory, and the problem is then usually solved. I can certainly live with this, but it would be cool to be able to do it for Workshop directly.

@memeplex What do you mean a different outdir? I currently have the single output directory for all subfiles. Do you mean having separate subdirectories for each subfile?

memeplex commented 5 months ago

I currently have the single output directory for all subfiles. Do you mean having separate subdirectories for each subfile?

No, just this, I didn't realize that you were already doing it. I mean, for the exceptional situations when the build process is messed up and you need a clean start you can easily delete everything in the folder. But if you want to do it from LW, and if want to keep the ability to remove aux files separately in general but altogether for some particular situations, you can easily add a new recipe for the "nuclear option".

Also notice that you don't need to delete everything to fix the building, but just the aux files for the current file.

kaba2 commented 5 months ago

Good to know that deleting .aux files suffice for a reset :) I don't really know the meaning of the various temporarily files. Maybe I'll then add the nuclear command myself.

memeplex commented 5 months ago

Good to know that deleting .aux files suffice for a reset :) I don't really know the meaning of the various temporarily files. Maybe I'll then add the nuclear command myself.

No, this is a misunderstanding, I was referring to aux files in general (it's latexmk terminology), not to .aux files in particular. My point is that if the build for document.tex is broken you just need to remove aux stuff for document.tex and not for section.tex that is a subfile. Remember that each build completely ignores files for other builds, be them aux or out files. So "fixing a build" is not really a compelling use case for a "remove everything" option.

kaba2 commented 5 months ago

I see. If so, then I agree that "remove everything" does not seem that useful. Perhaps I'll be just fine with the current Clean.