I'm trying to get a word count of my latex doc, but the command fails.
The word count is supposed to be displayed
Error message: TeXcount failed
Cannot count words, code: 1, texcount: The script could not be found.
texcount: Data: scriptEngine="perl", name="texcount", path="scripts/texcount/texcount.pl"
LaTeX Workshop Output
Developer Tools Console
texcount requires perl. It seems that your env does not have it installed. Is texcount working correctly in command line?
Perl is installed and working; if it wasn't, I would see an error message about it not being installed. If I type "perl C:Program FilesMiKTeX 2.9scriptstexcounttexcount.pl" on the command line, things are working fine. The issue is that VSCE cannot find the path. I guess I don't understand how I should set the corresponding variable so that it does.
Hmm, or is the issue that there is currently no filetype association for perl on my system? Is the command issued by VSCE simply "C:Program FilesMiKTeX 2.9scriptstexcounttexcount.pl"?
It only calls texcount and let bash do the rest. So that seems to be the problem.
Yes. Am I correct in assuming you are running this on Linux or a Mac? So the call that is issued by VSCE is simply texcount? The problem with that on Windows is that the command interpreter, in contrast to bash, does not interpret the first line in a script such as texcount.pl to find the executable to run it with.
I wonder if on Windows I can just set texcount to something like "wperl C:Program FilesMiKTeX 2.9scriptstexcounttexcount.pl" (using wperl instead of perl so there's no command window popping up). Even if I do that, there might still be an issue with correctly piping the output of the perl script back to wherever VSCE needs it.
I'll report back, not on my computer right now.
Nope, that was a no-go: I get "Cannot count words: spawn perl C:Program FilesMiKTeX 2.9scriptstexcounttexcount.pl ENOENT"
P.S.: Given these Windows issues, I think it might be a good idea to re-open this one, and/or mention restrictions regarding usage under Windows in the documentation.
I'm developing the extension using Windows and Linux. There is no problem on my side. I'd say it can be a TeX distribution problem. Until texcount itself works under command line tools, the counter won't work afaik.
Hah, I got it now: I didn't realize that this function relies on an executable, _texcount.exe_, that is part of my MikTeX distribution. The issue was that apparently the texcount package under MikTeX is misconfigured (out of the box, I think), and has the texcount.pl script in the wrong location. I had fixed that and copied the script to the right location, but texcount still would not work because it relies on MikTeX's file name database to find it. I updated the FNDB and now everything is running exactly as it should.
Thanks for your patience with this! I hope the above can help someone...
How did you update the FNDB after moving the script file into the "perl" folder?
I used the MikTeX Settings utility that gets installed together with MikTeX.
It has a button labeled "Refresh FNDB" which does the trick.
Sorry, I should've been more specific.
The script that comes with texcount is in scripts/texcount/texcount.pl instead of being in scripts/texcount/perl/texcount.pl
I created a folder "perl" and I moved texcount.pl there. I ran the Update / Refresh FNDB using MikTeX Settings (Admin), yet the properties of the package in the MikTeX Package Manager is showing the scripts/texcount/texcount.pl rather than the modified one.
Did I miss a step? what do you mean by "I had fixed that" in your post? Do I need to add / edit a config file?
I meant that if I now ask vscode to count words it returns the word count rather than an error message. I think what you did should work; my issue had been that the system could not find _texcount.exe_ (for reasons that are unclear), and updating the FNDB had fixed that for me.
I also cannot get word count. When I click "Count Words in LaTeX project", nothing happens. No error message, no word count neither. I have installed perl and texcount.pl. It works in the terminal.
I also cannot get word count. When I click "Count Words in LaTeX project", nothing happens. No error message, no word count neither. I have installed perl and texcount.pl. It works in the terminal.
The same is happening to me, altough there is no output when i use texcount from the terminal either