James-Yu / LaTeX-Workshop

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

error when parsing file/reference #3571

Closed daviehh closed 1 year ago

daviehh commented 1 year ago

Preliminary questions [Required]

Disable all the other extensions except for LaTeX Workshop, restart VS Code, and check that you still see this issue. [Required]

You still see this issue?: Yes

Make sure to visit the wiki FAQ before filling an issue.

You visited the wiki?: Yes

If your issue is with compiling a document (not having to do with finding the root file of a project), check first that you can compile manually.

You can compile a TeX document manually?: Yes

Describe the bug [Required]

For the minimum example file below, compiling the file (clearing all auxiliary compilation temporary files), the error message

Expected ",", "=", "\r\n", [ \t\n], or [^@={}", \t\r\n] but "}" found.

is shown, and the extension is 'stuck' and the compile command no longer triggers a compile.

To Reproduce

Steps to reproduce the behavior:

latex file:

\documentclass[aps,pra,showpacs,twocolumn,superscriptaddress]{revtex4-1}

% \usepackage{natbib}

\begin{document}

\title{testing}

Testing \cite{test_ref}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{thebibliography}{1}

    \bibitem{test_ref}
    M.~B. Far{\'\i}as {\it et~al.}, NPJ Quantum Inf. {\bf 6}, 1 (2020).

\end{thebibliography}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}

Expected behavior

Compiles the file (command line latexmk works fine)

Logs [Required]

Please paste the whole log messages here, not parts of ones. The log should start with Initializing LaTeX Workshop. It is very important to identify problems.

LaTeX Workshop Output [Required]

[15:28:30] Initializing LaTeX Workshop.
[15:28:30] Extension root: /Users/david/.vscode/extensions/james-yu.latex-workshop-9.1.0
[15:28:30] $PATH: /Users/david/.juliaup/bin:/Users/david/.mconda/bin:/opt/homebrew/Caskroom/miniforge/base/condabin:/usr/local/MacGPG2/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/MacGPG2/bin:/opt/X11/bin:/Library/Apple/usr/bin:/usr/local/git/bin:/usr/local/sbin:/usr/local/bin:/Users/david/.local/bin:/usr/local/opt/fzf/bin
[15:28:30] $SHELL: /opt/homebrew/bin/zsh
[15:28:30] $LANG: en_US.UTF-8
[15:28:30] $LC_ALL: undefined
[15:28:30] process.platform: darwin
[15:28:30] process.arch: arm64
[15:28:30] vscode.env.appName: Visual Studio Code
[15:28:30] vscode.env.remoteName: undefined
[15:28:30] vscode.env.uiKind: 1
[15:28:30] Configuration for workspace: file:///Users/david/Downloads/tmp/s
[15:28:30] editor.acceptSuggestionOnEnter: "on"
[15:28:30] latex-workshop.bind.enter.key: true
[15:28:30] latex-workshop.docker.enabled: false
[15:28:30] latex-workshop.docker.image.latex: ""
[15:28:30] latex-workshop.hover.preview.mathjax.extensions: []
[15:28:30] latex-workshop.intellisense.package.enabled: true
[15:28:30] latex-workshop.intellisense.update.aggressive.enabled: false
[15:28:30] latex-workshop.intellisense.update.delay: 1000
[15:28:30] latex-workshop.latex.autoBuild.run: "onFileChange"
[15:28:30] latex-workshop.latex.build.forceRecipeUsage: true
[15:28:30] latex-workshop.latex.outDir: "%DIR%"
[15:28:30] latex-workshop.latex.recipes: [
 {
  "name": "latexmk 🔃",
  "tools": [
   "latexmk"
  ]
 },
 {
  "name": "latexmk (latexmkrc)",
  "tools": [
   "latexmk_rconly"
  ]
 },
 {
  "name": "latexmk (lualatex)",
  "tools": [
   "lualatexmk"
  ]
 },
 {
  "name": "latexmk (xelatex)",
  "tools": [
   "xelatexmk"
  ]
 },
 {
  "name": "pdflatex ➞ bibtex ➞ pdflatex × 2",
  "tools": [
   "pdflatex",
   "bibtex",
   "pdflatex",
   "pdflatex"
  ]
 },
 {
  "name": "Compile Rnw files",
  "tools": [
   "rnw2tex",
   "latexmk"
  ]
 },
 {
  "name": "Compile Jnw files",
  "tools": [
   "jnw2tex",
   "latexmk"
  ]
 },
 {
  "name": "tectonic",
  "tools": [
   "tectonic"
  ]
 }
]
[15:28:30] latex-workshop.latex.tools: [
 {
  "name": "latexmk",
  "command": "latexmk",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "-pdf",
   "-outdir=%OUTDIR%",
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "lualatexmk",
  "command": "latexmk",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "-lualatex",
   "-outdir=%OUTDIR%",
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "xelatexmk",
  "command": "latexmk",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "-xelatex",
   "-outdir=%OUTDIR%",
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "latexmk_rconly",
  "command": "latexmk",
  "args": [
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "pdflatex",
  "command": "pdflatex",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "%DOC%"
  ],
  "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": "jnw2texmintex",
  "command": "julia",
  "args": [
   "-e",
   "using Weave; weave(\"%DOC_EXT%\", doctype=\"texminted\")"
  ],
  "env": {}
 },
 {
  "name": "tectonic",
  "command": "tectonic",
  "args": [
   "--synctex",
   "--keep-logs",
   "%DOC%.tex"
  ],
  "env": {}
 }
]
[15:28:30] latex-workshop.viewer.pdf.internal.keyboardEvent: "auto"
[15:28:30] Creating a new file watcher.
[15:28:30] watcherOptions: {"useFsEvents":false,"usePolling":false,"interval":300,"binaryInterval":1000,"awaitWriteFinish":{"stabilityThreshold":250}}
[15:28:30] Creating PDF file watcher.
[15:28:30] watcherOptions: {"useFsEvents":false,"usePolling":false,"interval":300,"binaryInterval":1000,"awaitWriteFinish":{}}
[15:28:30] Creating Bib file watcher.
[15:28:30] watcherOptions: {"useFsEvents":false,"usePolling":false,"interval":300,"binaryInterval":1000,"awaitWriteFinish":{"stabilityThreshold":250}}
[15:28:30] Set $LATEXWORKSHOP_DOCKER_LATEX: ""
[15:28:30] [Server] Creating LaTeX Workshop http and websocket server.
[15:28:30] LaTeX Workshop initialized.
[15:28:30] Trigger characters for intellisense of LaTeX documents: ["\\",",","{"]
[15:28:30] Bibtex format config: {"tab":"  ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]}
[15:28:30] Current workspace folders: ["file:///Users/david/Downloads/tmp/s"]
[15:28:30] Found root file from active editor: /Users/david/Downloads/tmp/s/suppl_mat.tex
[15:28:30] Root file changed: from undefined to /Users/david/Downloads/tmp/s/suppl_mat.tex
[15:28:30] Start to find all dependencies.
[15:28:30] Root file languageId: latex
[15:28:30] Reset file watcher.
[15:28:30] Parsing a file and its subfiles: /Users/david/Downloads/tmp/s/suppl_mat.tex
[15:28:30] Parse fls file.
[15:28:30] Cannot find fls file: /Users/david/Downloads/tmp/s/suppl_mat.fls
[15:28:30] [Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":55641}
[15:28:30] Added to file watcher: /Users/david/Downloads/tmp/s/suppl_mat.tex
[15:28:30] Snippet data loaded.
[15:28:30] [Server] valdOrigin is http://127.0.0.1:55641
[15:28:30] Checking for duplicate labels: /Users/david/Downloads/tmp/s/suppl_mat.tex.
[15:28:32] BUILD command invoked.
[15:28:32] The document of the active editor: file:///Users/david/Downloads/tmp/s/suppl_mat.tex
[15:28:32] The languageId of the document: latex
[15:28:32] Current workspace folders: ["file:///Users/david/Downloads/tmp/s"]
[15:28:32] Found root file from active editor: /Users/david/Downloads/tmp/s/suppl_mat.tex
[15:28:32] Keep using the same root file: /Users/david/Downloads/tmp/s/suppl_mat.tex
[15:28:32] Building root file: /Users/david/Downloads/tmp/s/suppl_mat.tex
[15:28:32] Build root file /Users/david/Downloads/tmp/s/suppl_mat.tex
[15:28:32] outDir: /Users/david/Downloads/tmp/s
[15:28:32] Recipe step 1: latexmk
[15:28:32] Recipe step 1 args: ["-synctex=1","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=/Users/david/Downloads/tmp/s","/Users/david/Downloads/tmp/s/suppl_mat"]
[15:28:32] Recipe step env: {}
[15:28:32] Recipe step root file: /Users/david/Downloads/tmp/s/suppl_mat.tex
[15:28:32] cwd: /Users/david/Downloads/tmp/s
[15:28:32] LaTeX build process spawned. PID: 4979.
[15:28:32] Manager.fileWatcher.getWatched: {"/Users/david/Downloads/tmp/s":["suppl_mat.tex"]}
[15:28:32] Manager.filesWatched: ["/Users/david/Downloads/tmp/s/suppl_mat.tex"]
[15:28:32] BibWatcher.bibWatcher.getWatched: {}
[15:28:32] BibWatcher.bibsWatched: []
[15:28:32] PdfWatcher.pdfWatcher.getWatched: {}
[15:28:32] PdfWatcher.pdfsWatched: []
[15:28:32] PdfWatcher.watchedPdfVirtualUris: []
[15:28:32] PdfWatcher.ignoredPdfUris: ["file:///Users/david/Downloads/tmp/s/suppl_mat.pdf"]
[15:28:33] BibTeX log parsed with 0 messages.
[15:28:33] LaTeX log parsed with 1 messages.
[15:28:33] A step in recipe finished. PID: 4979.
[15:28:33] Successfully built /Users/david/Downloads/tmp/s/suppl_mat.tex.
[15:28:33] Call refreshExistingViewer: {"sourceFile":"/Users/david/Downloads/tmp/s/suppl_mat.tex"}
[15:28:33] Not found PDF viewers to refresh: file:///Users/david/Downloads/tmp/s/suppl_mat.pdf
[15:28:33] Parse fls file.
[15:28:33] Fls file found: /Users/david/Downloads/tmp/s/suppl_mat.fls
[15:28:33] Parse aux file: /Users/david/Downloads/tmp/s/suppl_mat.aux
[15:28:33] Found .bib file: /Users/david/Downloads/tmp/s/suppl_matNotes.bib
[15:28:33] Added to bib file watcher: /Users/david/Downloads/tmp/s/suppl_matNotes.bib
[15:28:33] Parsing .bib entries from /Users/david/Downloads/tmp/s/suppl_matNotes.bib
[15:28:33] Error parsing BibTeX: line 1 in /Users/david/Downloads/tmp/s/suppl_matNotes.bib.
[15:28:59] Current workspace folders: ["file:///Users/david/Downloads/tmp/s"]
[15:28:59] Found root file from active editor: /Users/david/Downloads/tmp/s/suppl_mat.tex
[15:28:59] Keep using the same root file: /Users/david/Downloads/tmp/s/suppl_mat.tex
[15:29:01] Current workspace folders: ["file:///Users/david/Downloads/tmp/s"]
[15:29:01] Found root file from active editor: /Users/david/Downloads/tmp/s/suppl_mat.tex
[15:29:01] Keep using the same root file: /Users/david/Downloads/tmp/s/suppl_mat.tex
[15:29:15] LOG command invoked: default

Developer Tools Console [Required]

TMScopeRegistry.ts:47 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/david/.vscode/extensions/james-yu.latex-workshop-9.1.0/syntax/TeX.tmLanguage.json
register @ TMScopeRegistry.ts:47
TMScopeRegistry.ts:47 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/david/.vscode/extensions/james-yu.latex-workshop-9.1.0/syntax/LaTeX.tmLanguage.json
register @ TMScopeRegistry.ts:47
TMScopeRegistry.ts:47 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/david/.vscode/extensions/james-yu.latex-workshop-9.1.0/syntax/Bibtex.tmLanguage.json
register @ TMScopeRegistry.ts:47
TMScopeRegistry.ts:47 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/david/.vscode/extensions/james-yu.latex-workshop-9.1.0/syntax/markdown-latex-combined.tmLanguage.json
register @ TMScopeRegistry.ts:47
TMScopeRegistry.ts:47 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/david/.vscode/extensions/james-yu.latex-workshop-9.1.0/syntax/cpp-grammar-bailout.tmLanguage.json
register @ TMScopeRegistry.ts:47
TMScopeRegistry.ts:47 Overwriting grammar scope name to file mapping for scope source.julia.
Old grammar file: file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/julia/syntaxes/julia.tmLanguage.json.
New grammar file: file:///Users/david/.vscode/extensions/julialang.language-julia-1.40.1/syntaxes/julia_vscode.json
register @ TMScopeRegistry.ts:47
log.ts:312  INFO [perf] Render performance baseline is 15ms
DevTools failed to load source map: Could not load content for https://file+.vscode-resource.vscode-cdn.net/Users/david/.vscode/extensions/james-yu.latex-workshop-9.1.0/node_modules/pdfjs-dist/build/pdf.js.map: Connection error: net::ERR_NAME_NOT_RESOLVED
DevTools failed to load source map: Could not parse content for vscode-webview://1ggji5eb0e9vbk6lpg5sj6tsd0aqkmdslu9uh6fgqpjm0077c5b7/pdf.worker.js.map: Unexpected end of JSON input

Screenshots

Screenshot 2022-12-03 at 3 28 37 PM

Desktop [Required]

Please write exact version numbers. Please don't write latest instead of exact numbers.

Additional questions

Are you using VSCodium?

No

Are you using the Snap or Flatpack versions of VS Code?

No

Are you using LaTeX Workshop with VS Code Remote?

No

If the answer is Yes, please write which one you are using. Write the versions of the remote extension.

Additional context

Looking through the log, there is a line

Error parsing BibTeX: line 1 in /Users/david/Downloads/tmp/s/suppl_matNotes.bib.

The content of the file is

@CONTROL{REVTEX41Control}
@CONTROL{apsrev41Control,author="08",editor="1",pages="0",title="",year="1"}
daviehh commented 1 year ago

Looks like the reason for the error is that the revtex template generates the file "{base tex filename}Notes.bib", which does not follow the bib file syntax. That file does not include entries for the auto-complete, so maybe we should skip the file "{base tex filename}Notes.bib" from the parser/watcher?