tecosaur / LaTeX-Utilities

An add-on to LaTeX Workshop that provides some features that go beyond the bare essentials
MIT License
474 stars 28 forks source link

texcount not working with extension despite working in terminal #392

Closed dirichlettt closed 6 months ago

dirichlettt commented 7 months ago

Bug Report

Disable all the other extensions except for LaTeX Workshop and LaTeX Utilities, and check that you still see this issue.

You still see this issue?: Yes

Describe the bug

Whenever I open a .tex file (even if the file compiles correctly), I see the message "TeXCount failed. Please refer to LaTeX Utilities Output for details." The output reads "Cannot count words: spawn texcount_issue/texcount.pl ENOENT, undefined" (I have texcount.pl and a tex file test.tex in a folder texcount_issue/). In my settings.json, I have

"latex-utilities.countWord.path": "texcount_issue/texcount.pl", 
"latex-workshop.texcount.path": "texcount_issue/texcount.pl",

However, when I manually run texcount using the same perl file, it runs perfectly:

image

To Reproduce

Steps to reproduce the behaviour:

  1. Have a working .tex file and texcount.pl somewhere with "latex-utilities.countWord.path" set to the path of texcount.pl
  2. Click on the .tex file from another tab or window
  3. The error should appear

Expected behaviour

The output should be (presumably) the same as when one runs texcount.pl manually.

Logs

LaTeX Workshop Output ``` [24:35:04.555][Logger] New log placeholder %WS1% registered for /home/soleil/texcount_issue . [24:35:04.555][Extension] Initializing LaTeX Workshop. [24:35:04.767][Build][Recipe] Set $LATEXWORKSHOP_DOCKER_LATEX: "" [24:35:04.880][Server] Creating LaTeX Workshop http and websocket server. [24:35:05.098][Format][Bib] Bibtex format config: {"tab":" ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]} [24:35:05.282][Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":34903} . [24:35:05.383][Extension] Extension root: /home/soleil/.vscode/extensions/james-yu.latex-workshop-9.18.0 [24:35:05.384][Extension] $PATH: /usr/local/texlive/2023/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin [24:35:05.384][Extension] $SHELL: /bin/bash [24:35:05.385][Extension] $LANG: en_US.UTF-8 [24:35:05.385][Extension] $LC_ALL: undefined [24:35:05.385][Extension] process.platform: linux [24:35:05.386][Extension] process.arch: x64 [24:35:05.386][Extension] vscode.env.appName: Visual Studio Code [24:35:05.386][Extension] vscode.env.remoteName: undefined [24:35:05.387][Extension] vscode.env.uiKind: 1 [24:35:05.390][Config] latex-workshop.latex.recipes: [{"name":"pdflatex","tools":["pdflatex"]},{"name":"latexmk","tools":["latexmk"]},{"name":"pdflatex -> bibtex -> pdflatex * 2","tools":["pdflatex","bibtex","pdflatex","pdflatex"]}] . [24:35:05.442][Config] latex-workshop.texcount.path: "texcount_issue/texcount.pl" . [24:35:05.513][Extension] Trigger characters for intellisense of LaTeX documents: ["\\",",","{"] [24:35:05.530][Root] Current workspace folders: ["file://%WS1%"] [24:35:05.531][Extension] LaTeX Workshop initialized. [24:35:05.532][Root] Found root file from active editor: %WS1%/test.tex [24:35:05.539][Root] Root file changed: from %WS1%/test.tex to %WS1%/test.tex, langID latex . Refresh dependencies [24:35:05.539][Event] ROOT_FILE_CHANGED: "%WS1%/test.tex" [24:35:05.542][Cacher][Watcher] Reset. [24:35:05.543][Cacher][Watcher] Reset. [24:35:05.544][Cacher][Watcher] Reset. [24:35:05.553][Cacher] Adding %WS1%/test.tex . [24:35:05.562][Cacher][Watcher] Watched %WS1%/test.tex with a new watcher on %WS1% . [24:35:05.563][Event] FILE_WATCHED: "%WS1%/test.tex" [24:35:05.565][Cacher] Caching %WS1%/test.tex . [24:35:05.567][Cacher] Updated inputs of %WS1%/test.tex . [24:35:05.567][Cacher] Parse LaTeX AST: %WS1%/test.tex . [24:35:05.567][Event] ROOT_FILE_SEARCHED [24:35:05.672][Cacher] Parsed LaTeX AST: %WS1%/test.tex . [24:35:05.673][File] Calling kpsewhich to resolve article.cls . [24:35:05.720][Cacher] Updated elements in 47.94 ms: %WS1%/test.tex . [24:35:05.721][Event] FILE_PARSED: "%WS1%/test.tex" [24:35:05.726][Structure] Structure force updated with 0 root sections for %WS1%/test.tex . [24:35:05.727][Event] STRUCTURE_UPDATED [24:35:05.736][Server] valdOrigin is http://127.0.0.1:34903 [24:35:58.914][Commander] BUILD command invoked. [24:35:58.916][Build] The document of the active editor: file://%WS1%/test.tex [24:35:58.917][Build] The languageId of the document: latex [24:35:58.918][Root] Current workspace folders: ["file://%WS1%"] [24:35:58.923][Root] Found root file from active editor: %WS1%/test.tex [24:35:58.925][Root] Keep using the same root file: %WS1%/test.tex [24:35:58.925][Event] ROOT_FILE_SEARCHED [24:35:58.926][Event] STRUCTURE_UPDATED [24:35:58.927][Build] Building root file: %WS1%/test.tex [24:35:58.927][Build][Recipe] Build root file %WS1%/test.tex [24:35:58.951][Build][Recipe] Preparing to run recipe: pdflatex. [24:35:58.952][Build][Recipe] Prepared 1 tools. [24:35:58.968][Build][Recipe] outDir: %WS1% . [24:35:58.971][Build] Recipe step 1 The command is pdflatex:["-synctex=1","-interaction=nonstopmode","-file-line-error","%WS1%/test"]. [24:35:58.971][Build] env: {} [24:35:58.972][Build] root: %WS1%/test.tex [24:35:58.973][Build] cwd: %WS1% [24:35:58.984][Build] LaTeX build process spawned with PID 101557. [24:35:59.201][Parser][TexLog] Logged 0 messages. [24:35:59.202][Build] Finished a step in recipe with PID 101557. [24:35:59.203][Build] Successfully built %WS1%/test.tex . [24:35:59.204][Event] BUILD_DONE [24:35:59.204][Viewer] Call refreshExistingViewer: "%WS1%/test.pdf" . [24:35:59.205][Viewer] Not found PDF viewers to refresh: %WS1%/test.pdf ```
LaTeX Utilities Output ``` [24:35:05] Initializing LaTeX Utilities. [24:35:05] Live Snippets Loaded [24:35:05] Completion Watcher Initialised [24:35:05] TexCount args: -merge,-brief [24:35:05] LaTeX Utilities Started [24:35:05] Cannot count words: spawn texcount_issue/texcount.pl ENOENT, undefined [24:35:05] LaTeX Utilities version: 0.4.10 [24:36:38] onDidChangeActiveTextEditor_tex_wordcounter [24:37:46] onDidChangeActiveTextEditor_tex_wordcounter [24:37:46] TexCount args: -merge,-brief [24:37:46] Cannot count words: spawn texcount_issue/texcount.pl ENOENT, undefined [24:37:48] onDidChangeActiveTextEditor_tex_wordcounter ```
Developer Tools Console

Screenshots

As seen above.

Desktop

Additional context

leoleoasd commented 7 months ago

Can you try put the absolute path of texcount to config?

panvas24 commented 6 months ago

I have the exact same issue with the following

LaTeX Utilities log:

[12:37:21] onDidChangeActiveTextEditor_tex_wordcounter
[12:37:21] TexCount args: -inc,-sum,-total,-merge,-brief
[12:37:21] Cannot count words: spawn UNKNOWN, undefined
[12:37:23] onDidChangeTextDocument
[12:37:23] onDidSaveTextDocument_tex_wordcounter
[12:37:23] TexCount args: -inc,-sum,-total,-merge,-brief
[12:37:23] Cannot count words: spawn UNKNOWN, undefined
[12:37:26] onDidChangeActiveTextEditor_tex_wordcounter

the absolute path of texcount is the following:

C:\\Users\\pvas\\AppData\\Local\\Programs\\MiKTeX\\scripts\\texcount\\texcount.pl

I am working on Windows 11 Pro Version: 21H2 Build: 22000.2538

leoleoasd commented 6 months ago

This extension assumes a texcount command in PATH. Can you try putting the path of the texcount.pl to latex-utilities.countWord.path setting entry?

leoleoasd commented 6 months ago

If it doesn't work, please re-open this issue.