James-Yu / LaTeX-Workshop

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

latexmk 4.84 fails with `-outdir` #4219

Closed incubus-ank closed 3 months ago

incubus-ank commented 3 months ago

Pre-checks*

Environment*

The Issue*

An error appears when building a tex document project. The compiler used is latexmk. In the terminal, compilation occurs successfully.

Reproduction Steps

Sorry, but I don't know how to reproduce the error on another machine. I just installed the basic version of tex live and latexmk. And I tried to compile the document. An error occurs during compilation. However, the PDF is created correctly. Given the auto assembly, the error appears every time you edit. The most interesting thing is that compilation in the terminal is successful and without errors.

Expected Behavior

I expect to see a compiled document with no error messages.

Logs

LaTeX Workshop Output*

[16:23:18.989][Logger] New log placeholder %WS1% registered for c:\Users\akraj\Desktop\latex .
[16:23:18.989][Extension] Initializing LaTeX Workshop.
[16:23:19.277][Build][Recipe] Set $LATEXWORKSHOP_DOCKER_LATEX: ""
[16:23:19.362][Server] Creating LaTeX Workshop http and websocket server.
[16:23:19.469][Format][Bib] Bibtex format config: {"tab":"    ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]}
[16:23:19.585][Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":55783} .
[16:23:19.609][Extension] Extension root: c:\Users\akraj\.vscode\extensions\james-yu.latex-workshop-9.19.1
[16:23:19.609][Extension] $PATH: C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\Pandoc\;C:\Program Files\WireGuard\;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Users\akraj\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\akraj\AppData\Local\Programs\Python\Python310\;C:\Users\akraj\AppData\Local\Programs\Python\Python312\Scripts\;C:\Users\akraj\AppData\Local\Programs\Python\Python312\;C:\Users\akraj\AppData\Local\Microsoft\WindowsApps;;C:\Users\akraj\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files (x86)\EShare\;C:\texlive\2024\bin\windows
[16:23:19.609][Extension] $SHELL: undefined
[16:23:19.609][Extension] $LANG: undefined
[16:23:19.610][Extension] $LC_ALL: undefined
[16:23:19.610][Extension] process.platform: win32
[16:23:19.610][Extension] process.arch: x64
[16:23:19.610][Extension] vscode.env.appName: Visual Studio Code
[16:23:19.610][Extension] vscode.env.remoteName: undefined
[16:23:19.610][Extension] vscode.env.uiKind: 1
[16:23:19.613][Config] latex-workshop.latex.tools: [{"name":"latexmk","command":"latexmk","args":["-synctex=1","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=%OUTDIR%","%DOC_EXT%"],"env":{}},{"name":"lualatexmk","command":"latexmk","args":["-synctex=1","-interaction=nonstopmode","-file-line-error","-lualatex","-outdir=%OUTDIR%","%DOC_EXT%"],"env":{}},{"name":"xelatexmk","command":"latexmk","args":["-synctex=1","-interaction=nonstopmode","-file-line-error","-xelatex","-outdir=%OUTDIR%","%DOC_EXT%"],"env":{}},{"name":"latexmk_rconly","command":"latexmk","args":["%DOC_EXT%"],"env":{}},{"name":"pdflatex","command":"pdflatex","args":["-synctex=1","-interaction=nonstopmode","-file-line-error","%DOC_EXT%"],"env":{}},{"name":"bibtex","command":"bibtex","args":["%DOCFILE%"],"env":{}},{"name":"rnw2tex","command":"Rscript","args":["-e","knitr::opts_knit$set(concordance = TRUE); knitr::knit('%DOCFILE_EXT%')"],"env":{}},{"name":"jnw2tex","command":"julia","args":["-e","using Weave; weave(\"%DOC_EXT%\", doctype=\"tex\")"],"env":{}},{"name":"jnw2texminted","command":"julia","args":["-e","using Weave; weave(\"%DOC_EXT%\", doctype=\"texminted\")"],"env":{}},{"name":"pnw2tex","command":"pweave","args":["-f","tex","%DOC_EXT%"],"env":{}},{"name":"pnw2texminted","command":"pweave","args":["-f","texminted","%DOC_EXT%"],"env":{}},{"name":"tectonic","command":"tectonic","args":["--synctex","--keep-logs","%DOC_EXT%.tex"],"env":{}}] .
[16:23:19.614][Config] latex-workshop.latex.outDir: "%DIR_W32%" .
[16:23:19.637][Config] latex-workshop.bibtex-format.tab: "4 spaces" .
[16:23:19.643][Extension] Trigger characters for intellisense of LaTeX documents: ["\\",",","{"]
[16:23:19.644][Root] Current workspace folders: ["file:///c:/Users/akraj/Desktop/latex"]
[16:23:19.645][Extension] LaTeX Workshop initialized.
[16:23:19.645][Root] Found root file from active editor: %WS1%\test.tex
[16:23:19.645][Root] Root file changed: from %WS1%\test.tex to %WS1%\test.tex, langID latex . Refresh dependencies
[16:23:19.645][Event] ROOT_FILE_CHANGED: "c:\\Users\\akraj\\Desktop\\latex\\test.tex"
[16:23:19.646][Cacher][Watcher] Reset.
[16:23:19.646][Cacher][Watcher] Reset.
[16:23:19.649][Cacher] Adding %WS1%\test.tex .
[16:23:19.650][Cacher][Watcher] Watched %WS1%\test.tex with a new .* watcher on %WS1% .
[16:23:19.650][Event] FILE_WATCHED: "c:\\Users\\akraj\\Desktop\\latex\\test.tex"
[16:23:19.651][Cacher] Caching %WS1%\test.tex .
[16:23:19.652][Cacher] Updated inputs of %WS1%\test.tex .
[16:23:19.652][Cacher] Parse LaTeX AST: %WS1%\test.tex .
[16:23:19.653][Event] ROOT_FILE_SEARCHED
[16:23:19.680][Server] valdOrigin is http://127.0.0.1:55783
[16:23:19.706][Cacher] Parsed LaTeX AST: %WS1%\test.tex .
[16:23:19.707][File] Calling kpsewhich to resolve article.cls .
[16:23:19.904][File] kpsewhich returned with 'c:/texlive/2024/texmf-dist/tex/latex/base/article.cls'.
[16:23:19.905][Cacher] Updated elements in 198.90 ms: %WS1%\test.tex .
[16:23:19.906][Event] FILE_PARSED: "c:\\Users\\akraj\\Desktop\\latex\\test.tex"
[16:23:19.909][Cacher] Parsing .fls %WS1%\test.fls .
[16:23:19.911][Cacher] Found .aux %WS1%\test.tex from .fls %WS1%\test.fls , parsing.
[16:23:19.912][Cacher] Parsed .aux %WS1%\test.tex .
[16:23:19.912][Cacher] Parsed .fls %WS1%\test.fls .
[16:23:19.912][Structure] Structure force updated with 0 root sections for %WS1%\test.tex .
[16:23:19.913][Event] STRUCTURE_UPDATED
[16:23:23.402][Event] STRUCTURE_UPDATED
[16:23:25.751][Commander] BUILD command invoked.
[16:23:25.751][Build] The document of the active editor: file:///c:/Users/akraj/Desktop/latex/test.tex
[16:23:25.751][Build] The languageId of the document: latex
[16:23:25.751][Root] Current workspace folders: ["file:///c:/Users/akraj/Desktop/latex"]
[16:23:25.751][Root] Found root file from active editor: %WS1%\test.tex
[16:23:25.752][Root] Keep using the same root file: %WS1%\test.tex
[16:23:25.752][Event] ROOT_FILE_SEARCHED
[16:23:25.752][Event] STRUCTURE_UPDATED
[16:23:25.752][Build] Building root file: %WS1%\test.tex
[16:23:25.752][Build][Recipe] Build root file %WS1%\test.tex
[16:23:25.754][Build][Recipe] Preparing to run recipe: latexmk.
[16:23:25.754][Build][Recipe] Prepared 1 tools.
[16:23:25.857][Build][Recipe] outDir: c:/Users/akraj/Desktop/latex .
[16:23:25.858][Build] Recipe step 1 The command is latexmk:["-synctex=1","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=c:/Users/akraj/Desktop/latex","c:/Users/akraj/Desktop/latex/test.tex"].
[16:23:25.858][Build] env: {}
[16:23:25.858][Build] root: %WS1%\test.tex
[16:23:25.858][Build] cwd: %WS1%
[16:23:25.866][Build] LaTeX build process spawned with PID 5796.
[16:23:26.347][Parser][TexLog] Logged 0 messages.
[16:23:26.347][Build] Recipe returns with error code 2/null on PID 5796.
[16:23:26.347][Build] Does the executable exist? $PATH: undefined, $Path: C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\Pandoc\;C:\Program Files\WireGuard\;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Users\akraj\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\akraj\AppData\Local\Programs\Python\Python310\;C:\Users\akraj\AppData\Local\Programs\Python\Python312\Scripts\;C:\Users\akraj\AppData\Local\Programs\Python\Python312\;C:\Users\akraj\AppData\Local\Microsoft\WindowsApps;;C:\Users\akraj\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files (x86)\EShare\;C:\texlive\2024\bin\windows, $SHELL: undefined
[16:23:26.348][Build] 'test.pdf' and 'c:/Users/akraj/Desktop/latex/test.pdf' are identical (not copied) at c:\texlive\2024\texmf-dist\scripts\latexmk\latexmk.pl line 5562.
  That failed, with message 'No such file or directory'
Reverting Windows console CPs to (in,out) = (866,866)
C:\texlive\2024\bin\windows\runscript.tlu:921: command failed with exit code 2:
perl.exe c:\texlive\2024\texmf-dist\scripts\latexmk\latexmk.pl -synctex=1 -interaction=nonstopmode -file-line-error -pdf -outdir=c:/Users/akraj/Desktop/latex c:/Users/akraj/Desktop/latex/test.tex

[16:23:26.348][Build] Cleaning auxiliary files and retrying build after toolchain error.
[16:23:26.348][Cleaner] Clean temporary files command The command is latexmk:["-outdir=c:/Users/akraj/Desktop/latex","-c","c:\\Users\\akraj\\Desktop\\latex\\test.tex"].
[16:23:26.358][Build] Recipe step 1 The command is latexmk:["-synctex=1","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=c:/Users/akraj/Desktop/latex","c:/Users/akraj/Desktop/latex/test.tex"].
[16:23:26.358][Build] env: {}
[16:23:26.358][Build] root: %WS1%\test.tex
[16:23:26.358][Build] cwd: %WS1%
[16:23:26.368][Build] LaTeX build process spawned with PID 14540.
[16:23:26.633][Event] AUTO_CLEANED
[16:23:26.868][Parser][TexLog] Logged 0 messages.
[16:23:26.868][Build] Recipe returns with error code 2/null on PID 14540.
[16:23:26.868][Build] Does the executable exist? $PATH: undefined, $Path: C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\Pandoc\;C:\Program Files\WireGuard\;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Users\akraj\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\akraj\AppData\Local\Programs\Python\Python310\;C:\Users\akraj\AppData\Local\Programs\Python\Python312\Scripts\;C:\Users\akraj\AppData\Local\Programs\Python\Python312\;C:\Users\akraj\AppData\Local\Microsoft\WindowsApps;;C:\Users\akraj\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files (x86)\EShare\;C:\texlive\2024\bin\windows, $SHELL: undefined
[16:23:26.868][Build] 'test.pdf' and 'c:/Users/akraj/Desktop/latex/test.pdf' are identical (not copied) at c:\texlive\2024\texmf-dist\scripts\latexmk\latexmk.pl line 5562.
  That failed, with message 'No such file or directory'
Reverting Windows console CPs to (in,out) = (866,866)
C:\texlive\2024\bin\windows\runscript.tlu:921: command failed with exit code 2:
perl.exe c:\texlive\2024\texmf-dist\scripts\latexmk\latexmk.pl -synctex=1 -interaction=nonstopmode -file-line-error -pdf -outdir=c:/Users/akraj/Desktop/latex c:/Users/akraj/Desktop/latex/test.tex

[16:23:31.695][Event] STRUCTURE_UPDATED

Latex Compiler

Initial Win CP for (console input, console output, system): (CP866, CP866, CP1251)
I changed them all to CP1251
Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 29 Mar. 2024. Version 4.84.
No existing .aux file, so I'll make a simple one, and require run of *latex.
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex':  Reasons for rerun
Category 'other':
  Rerun of 'pdflatex' forced or previously required:
    Reason or flag: 'Initial setup'

------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex  -synctex=1 -interaction=nonstopmode -file-line-error -recorder  "c:/Users/akraj/Desktop/latex/test.tex"'
------------
This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(c:/Users/akraj/Desktop/latex/test.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-03-14>
(c:/texlive/2024/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(c:/texlive/2024/texmf-dist/tex/latex/base/size10.clo)) (c:/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def) (./test.aux) [1{c:/texlive/2024/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./test.aux) )<c:/texlive/2024/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on test.pdf (1 page, 14106 bytes).
SyncTeX written on test.synctex.gz.

Transcript written on test.log.
'test.pdf' and 'c:/Users/akraj/Desktop/latex/test.pdf' are identical (not copied) at c:\texlive\2024\texmf-dist\scripts\latexmk\latexmk.pl line 5562.
  That failed, with message 'No such file or directory'
Reverting Windows console CPs to (in,out) = (866,866)
Latexmk: Getting log file 'test.log'
Latexmk: Examining 'test.fls'
Latexmk: Examining 'test.log'
Latexmk: Log file says output to 'test.pdf'
================='.', 'c:/Users/akraj/Desktop/latex' '', 'c:/Users/akraj/Desktop/latex/'
Latexmk: Copying 'test.pdf' to 'c:/Users/akraj/Desktop/latex/test.pdf'
C:\texlive\2024\bin\windows\runscript.tlu:921: command failed with exit code 2:
perl.exe c:\texlive\2024\texmf-dist\scripts\latexmk\latexmk.pl -synctex=1 -interaction=nonstopmode -file-line-error -pdf -outdir=c:/Users/akraj/Desktop/latex c:/Users/akraj/Desktop/latex/test.tex
James-Yu commented 3 months ago

Thanks for reporting. Unfortunately, your issue is not related to the extension. You may want to search for the error message by latexmk on Google or other places for resolution.

James-Yu commented 3 months ago

Also, generally latexmk does not require the source file extension to present. I’m not sure if you were copying config values from random online posts. For your usage, the default config should work perfectly.

AlexaraWu commented 3 months ago

This issue caused by the new behavior of option -outdir introduced in latexmk version 4.84.

If you want output directory to be same as the root file directory, just remove -outdir=%OUTDIR% option in default recipe configs.

James-Yu commented 3 months ago

I don't see any changes to -outdir in latexmk v. 4.84.

From v. 4.83 to 4.84
  Update example_rcfiles/bib2gls_latexmkrc to deal with situation where
    .glstex file has basename of .bib file rather than that of main .tex
   file.
  Update example_rcfiles/asymptote_latexmkrc.
  Update example_rcfiles/splitindex_latexmkrc.
  Add example_rcfiles/memoize_latexmkrc.
  Improve detection of need to run makeindex (solves non-detection when
    imakeidx package is used with splitindex option).
  Implement final-output directory, with option -out2dir, variables
    $out2_dir, @out2_exts.
  Document hook mechanism.
  Document $allow_subdir_creation variable.
incubus-ank commented 3 months ago

Thanks for the help. Of course, I looked for mentions of this error on the Internet, but I didn’t find anything similar. I assumed that the error occurs due to inappropriate settings, for example the need to use a backslash. I experimented with the settings, but this did not lead to a solution to the problem. I removed the extension. I cleared the settings and installed again, the error repeated.

However, the solution that helped was removing the outdir parameter. I am attaching a working config of the tool latexmk for me.

"latex-workshop.latex.tools": [

        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "%DOC%"
            ],
            "env": {}
        },
jlelong commented 3 months ago

I do confirm an issue with latexmk 4.84 when using the -outdir option. Running latemk -outdir=/tmp/poo myfile.tex fails with the error

'/tmp/poo/myfile.pdf' and '/tmp/poo/myfile.pdf' are identical (not copied) at /Library/TeX/texbin/latexmk line 5562.
  That failed, with message 'No such file or directory'

It seems to be a bug of latexmk. I have just sent a message to John Collins who is the current maintainer of latexmk.

James-Yu commented 3 months ago

The -outdir arg was added in #1079 . It seems that the arg can be safely remove for now?

jlelong commented 3 months ago

Here's the reply of John Collins

The problem is associated with a new feature of v. 4.84 where there's a new kind of output directory, the final-output directory (e.g., set by the option -out2dir). The bug you encountered was triggered by the use of an absolute instead of a relative pathname poo for the output directory.

I'll get a fix out as soon as I can, and meanwhile, I'm reverting the version on CTAN to 4.83.

I hope few users have installed this buggy version.