James-Yu / LaTeX-Workshop

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

The root file search is not followed as documented #4083

Closed emiliogq closed 10 months ago

emiliogq commented 10 months ago

Pre-checks*

Environment*

The Issue*

The root file is not found even though I used the settings latex-workshop.latex.search.rootFiles.include and latex-workshop.latex.texDirs in the .vscode/settings.json. It seems it only tries to analyze only the current active file in the editor.

The structure of the workspace is the following:

.
├── .gitignore
├── .vscode
│   ├── launch.json
│   └── settings.json
├── README.md
├── build
│   └── doc
│       └── report
└── doc
    ├── article
    │   ├── .vscode
    │   ├── acronyms.tex
    │   ├── bibliography.bib
    │   ├── diagrams
    │   ├── glossary.tex
    │   ├── images
    │   ├── latexmkrc
    │   ├── main.pdf
    │   ├── main.synctex.gz
    │   ├── main.tex
    │   └── sections
    ├── report
    │   ├── 0_summary.tex
    │   ├── 0_title.tex
    │   ├── 1_introduction.tex
    │   ├── figs
    │   ├── images
    │   ├── main.tex
    │   └── references.bib
    └── uml

Reproduction Steps

  1. Go to the Latex Workshop extension
  2. Click on "Build LaTex project"

Configuration files

.vscode/settings.json

    "latex-workshop.latex.outDir": "%WORKSPACE_FOLDER%/build/%RELATIVE_DIR%",
    "latex-workshop.latex.search.rootFiles.include": [
        // Default value:  "**/*.tex",
        "doc/**/*.tex"
    ],
    "latex-workshop.latex.texDirs": [
        "%WORKSPACE_FOLDER/doc/article",
        "%WORKSPACE_FOLDER/doc/report"
    ]

Expected Behavior

What I expect is the latex extension finds the root file under the doc/article OR doc/report directories. The thing here is that the root find process does not falls down into the 3rd step (Root directory check).

Although I would like to be able to compile both directories having their own main root files in a single run, this behaviour is not expected by now.

Logs

LaTeX Workshop Output*

Run without no active files opened:

[21:29:24.661][Commander] BUILD command invoked.
[21:29:24.662][Commander] Cannot start to build because the active editor is undefined.
[21:29:33.271][Commander] SHOWLOG command invoked: default

Run with other active file than the main root files of any of article, report directories:

[21:47:02.774][Commander] BUILD command invoked.
[21:47:02.774][Commander] The document of the active editor: file://%WS1%/README.md
[21:47:02.775][Commander] The languageId of the document: markdown
[21:47:02.775][Commander] Cannot find LaTeX root file. See https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#the-root-file

Developer Tools Console

Developer Console Log ``` log.ts:431 WARN Via 'product.json#extensionEnabledApiProposals' extension 'ms-dotnettools.dotnet-interactive-vscode' wants API proposal 'languageConfigurationAutoClosingPairs' but that proposal DOES NOT EXIST. Likely, the proposal has been finalized (check 'vscode.d.ts') or was abandoned. log.ts:441 ERR Error: The editor could not be opened because the file was not found. at O.fc (textFileEditor.ts:206:52) at async O.setInput (textFileEditor.ts:156:4) at async c.S (editorPanes.ts:445:4) at async c.L (editorPanes.ts:270:34) at async c.openEditor (editorPanes.ts:146:12) at async editorGroupView.ts:1091:49 log.ts:431 WARN [twxs.cmake]: Cannot register 'cmake.cmakePath'. This property is already registered. log.ts:441 ERR Assertion Failed: argument is undefined or null: Error: Assertion Failed: argument is undefined or null at a (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:93:10215) at k.setInput (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2396:4548) at async k.setInput (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2396:11231) at async k.setInput (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2400:3886) log.ts:421 INFO [perf] Render performance baseline is 16ms log.ts:431 WARN [cmake-tools]: Couldn't find message for key cmake-tools.configuration.cmake.options.advanced.statusBarVisibility.variant.description. TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex. Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/TeX.tmLanguage.json. New grammar file: file:///Users/emiliogq/.vscode/extensions/james-yu.latex-workshop-9.15.0/syntax/TeX.tmLanguage.json register @ TMScopeRegistry.ts:46 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.latex. Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/LaTeX.tmLanguage.json. New grammar file: file:///Users/emiliogq/.vscode/extensions/james-yu.latex-workshop-9.15.0/syntax/LaTeX.tmLanguage.json register @ TMScopeRegistry.ts:46 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.bibtex. Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/Bibtex.tmLanguage.json. New grammar file: file:///Users/emiliogq/.vscode/extensions/james-yu.latex-workshop-9.15.0/syntax/Bibtex.tmLanguage.json register @ TMScopeRegistry.ts:46 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.markdown_latex_combined. Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/markdown-latex-combined.tmLanguage.json. New grammar file: file:///Users/emiliogq/.vscode/extensions/james-yu.latex-workshop-9.15.0/syntax/markdown-latex-combined.tmLanguage.json register @ TMScopeRegistry.ts:46 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope source.cpp.embedded.latex. Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/cpp-grammar-bailout.tmLanguage.json. New grammar file: file:///Users/emiliogq/.vscode/extensions/james-yu.latex-workshop-9.15.0/syntax/cpp-grammar-bailout.tmLanguage.json register @ TMScopeRegistry.ts:46 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope source.java. Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/java/syntaxes/java.tmLanguage.json. New grammar file: file:///Users/emiliogq/.vscode/extensions/redhat.java-1.25.0-darwin-arm64/language-support/java/java.tmLanguage.json register @ TMScopeRegistry.ts:46 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex. Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/TeX.tmLanguage.json. New grammar file: file:///Users/emiliogq/.vscode/extensions/james-yu.latex-workshop-9.15.0/syntax/TeX.tmLanguage.json register @ TMScopeRegistry.ts:46 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.latex. Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/LaTeX.tmLanguage.json. New grammar file: file:///Users/emiliogq/.vscode/extensions/james-yu.latex-workshop-9.15.0/syntax/LaTeX.tmLanguage.json register @ TMScopeRegistry.ts:46 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.bibtex. Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/Bibtex.tmLanguage.json. New grammar file: file:///Users/emiliogq/.vscode/extensions/james-yu.latex-workshop-9.15.0/syntax/Bibtex.tmLanguage.json register @ TMScopeRegistry.ts:46 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.markdown_latex_combined. Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/markdown-latex-combined.tmLanguage.json. New grammar file: file:///Users/emiliogq/.vscode/extensions/james-yu.latex-workshop-9.15.0/syntax/markdown-latex-combined.tmLanguage.json register @ TMScopeRegistry.ts:46 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope source.cpp.embedded.latex. Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/latex/syntaxes/cpp-grammar-bailout.tmLanguage.json. New grammar file: file:///Users/emiliogq/.vscode/extensions/james-yu.latex-workshop-9.15.0/syntax/cpp-grammar-bailout.tmLanguage.json register @ TMScopeRegistry.ts:46 TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope source.java. Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/java/syntaxes/java.tmLanguage.json. New grammar file: file:///Users/emiliogq/.vscode/extensions/redhat.java-1.25.0-darwin-arm64/language-support/java/java.tmLanguage.json register @ TMScopeRegistry.ts:46 10An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can escape its sandboxing. index.html?id=9c211442-5d38-4402-925a-32ca7624e12f&origin=d8a3a87f-dda8-4141-b49f-c3ae9dba69b9&swVersion=4&extensionId=James-Yu.latex-workshop&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app&purpose=webviewView:269 No service worker controller found. Waiting for controllerchange. notificationsAlerts.ts:42 Recipe terminated with error. c @ notificationsAlerts.ts:42 2log.ts:441 ERR TextModelPart is disposed!: Error: TextModelPart is disposed! at d.g (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:121:22451) at d.getWordAtPosition (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:631:119008) at W.getWordAtPosition (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:736:9056) at k.h (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:68470) at new $ (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:68345) at new k (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:69207) at D (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:69734) at O.G (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:74294) at O.F (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:74091) at new O (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:70761) at q (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:75166) at u.value (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:75311) at f.y (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:87:1902) at f.z (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:87:1972) at f.fire (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:87:2188) at x.setModel (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:744:400) at k.setInput (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2396:11447) at async k.setInput (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2400:3886) log.ts:441 ERR TextModelPart is disposed!: Error: TextModelPart is disposed! at d.g (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:121:22451) at d.getWordAtPosition (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:631:119008) at W.getWordAtPosition (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:736:9056) at k.h (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:68470) at new $ (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:68345) at new k (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:69207) at D (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:69734) at O.G (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:74294) at O.F (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:74091) at u.value (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:70483) at f.y (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:87:1902) at f.z (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:87:1972) at f.fire (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:87:2188) at x.setModel (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:744:400) at k.setInput (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2396:11447) at async k.setInput (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2400:3886) log.ts:441 ERR TextModelPart is disposed!: Error: TextModelPart is disposed! at d.g (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:121:22451) at d.getWordAtPosition (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:631:119008) at W.getWordAtPosition (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:736:9056) at O.D (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:72863) at O.F (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:73546) at O.C (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:72775) at u.value (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:760:70339) at f.y (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:87:1902) at f.z (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:87:1972) at f.fire (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:87:2188) at u.value (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:744:15864) at f.y (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:87:1902) at f.fire (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:87:2119) at I.s (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:132:108107) at I.endEmitViewEvents (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:132:108608) at $.S (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:742:4025) at $.setCursorStates (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:742:2012) at N.runCoreEditorCommand (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:681:12065) at L.moveTo (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:681:39250) at L.dispatchMouse (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:681:39084) at i.G (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:719:18001) at i.start (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:719:16305) at v.G (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:719:14678) at vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:719:12220 at HTMLDivElement. (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:714:30554) DevTools failed to load source map: Could not load content for https://file+.vscode-resource.vscode-cdn.net/Users/emiliogq/.vscode/extensions/james-yu.latex-workshop-9.15.0/node_modules/pdfjs-dist/build/pdf.mjs.map: Connection error: net::ERR_NAME_NOT_RESOLVED DevTools failed to load source map: Could not load content for vscode-webview://0u8959mg1ocheutdjd8cbumpall4ejo4qk8id3jv2t5mcodk8b87/pdf.worker.mjs.map: Unexpected end of JSON input ```

Anything Else?

Thanks for this amazing extension

James-Yu commented 10 months ago

It only searches for the root folder as documented. Sub folders won’t be checked. You really cannot rely on users to maintain a small number of Tex files in the directory tree, so this won’t be changed unfortunately.

emiliogq commented 10 months ago

Thanks for the quick reply. Then, is there no way to indicate to the extension where it should search?

Thanks in advance

It only searches for the root folder as documented. Sub folders won’t be checked. You really cannot rely on users to maintain a small number of Tex files in the directory tree, so this won’t be changed unfortunately.

James-Yu commented 10 months ago

No. You can create workspace-wise tool and recipe to do so.

emiliogq commented 10 months ago

Could you point/guide me how to do so?

No. You can create workspace-wise tool and recipe to do so.

As far as the recipe is concerned, I think is much clearer, I just need to call the custom tool (latexmk), but I don't see how pass the directories that I'm interested in:

{
    "latex-workshop.latex.outDir": "%WORKSPACE_FOLDER%/build/%RELATIVE_DIR%",
    "latex-workshop.latex.recipes": [
        {
          "name": "latexmk",
          "tools": [
            "latexmk"
          ]
        },
        {
          "name": "pdflatex -> bibtex -> pdflatex * 2",
          "tools": [
            "pdflatex",
            "bibtex",
            "pdflatex",
            "pdflatex"
          ]
        },
        {
            "name" : "Custom latexmk recipe",
            "tools": [
                "custom-latexmk"
            ]
        }
      ],
      "latex-workshop.latex.tools": [
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {}
        },
       /* Other tools removed */
        {
            "name": "custom-latexmk",
            "command": "latexmk",
            "args":[
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {}
        }
      ]

}

Thanks in advance

jlelong commented 10 months ago

You can use multi-root workspaces https://code.visualstudio.com/docs/editor/multi-root-workspaces Create a workspace and add the two folders article and report to it as roots. Then, the extension will pick the correct rootfile depending the workspace root.

I don't think you will need to tweak the recipes or tools.