LaTeX-Workshop: Cannot find LaTeX root file

Describe the bug

LaTeX Workshop does not build the document on save of a subfile.

To Reproduce Create main file test.tex with:

\documentclass{book}


\begin{document}
\mainmatter
\include{./file}
\end{document}

Subfile file.tex with:

% !TEX root = ./test.tex  

\chapter{Second file}
 test test asdf bla bal asdfa
\endinput

Expected behavior Document is being built on save of the subfile.

Logs

[17:03:52] File watcher: responding to change in d:\Demo\file.tex
[17:03:52] Parsing d:\Demo\file.tex
[17:03:52] Auto-build d:\Demo\file.tex upon save.
[17:03:52] BUILD command invoked.
[17:03:53] Cannot find LaTeX root file.

Screenshots code_2019-02-09_17-13-03

Desktop (please complete the following information):

  • OS: Windows 10
  • VS Code version: 1.31
  • Extension version: 5.21.0

Additional context In my actual document I also got the error message: extension-output-#3 is not a valid LaTeX file. but I couldn’t reproduce that. The bug first appeared today when the tex symbol in the very left sidebar appeared for the first time. Yesterday the same document worked even without the magic comment.

EDIT: Now I also sometimes get ACTIONS command invoked. after which the Build symbols circles endlessly without result.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 22

Most upvoted comments

I’m having a similar issue. It seems to appear when the current focus is not on a .tex file. E.g. when editing my .gitignore in a divided window parallel to my main.tex file and then press latexmk I get the error. But when bringing focus to my main.tex it works. Maybe that’s the reason.