When trying to format a .tex document (Alt+Shift+F) it does not work due to there being a space (punctuation) in the paths.
I've had a similar issue with the Maven for Java extension: See the issue here
Might be related to #485, #786
When building a latex project everything works fine, but there is an error related to an .aux file appearing in the developer console. I'm not sure this is related - But I've included this log under it's own section for just in case.
Steps to reproduce the behavior:
When using the _Format Document_ command, it should reformat the document.
[00:14:56] Formatting with command c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\scripts\latexindent.bat -c,c:/Users/Mr Sinamun/Projects/web3/scratch/,c:/Users/Mr Sinamun/Projects/web3/scratch/__latexindent_temp.tex,-y=defaultIndent: ' '
[00:14:56] Formatting failed with exit code 1
[00:14:56] stderr: 'c:\Users\Mr' is not recognized as an internal or external command,
operable program or batch file.
Formatting failed. Please refer to LaTeX Workshop Output for details.
[00:47:25] File watcher: responding to change in c:\Users\Mr Sinamun\Projects\web3\scratch\lalala.tex
[00:47:25] Parsing c:\Users\Mr Sinamun\Projects\web3\scratch\lalala.tex
[00:47:25] c:\Users\Mr Sinamun\Projects\web3\scratch\lalala.tex changed. Auto build project.
[00:47:25] BUILD command invoked.
[00:47:25] Building root file: c:\Users\Mr Sinamun\Projects\web3\scratch\lalala.tex
[00:47:25] Build root file c:\Users\Mr Sinamun\Projects\web3\scratch\lalala.tex
[00:47:25] Recipe step 1: c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\scripts\latexmk.bat, -synctex=1,-interaction=nonstopmode,-file-line-error,-pdf,-outdir=./,lalala
[00:47:25] LaTeX build process spawned. PID: 17488.
[00:47:26] Recipe of length 1 finished. PID: 17488.
[00:47:26] Successfully built c:\Users\Mr Sinamun\Projects\web3\scratch\lalala.tex.
[00:47:26] Refresh PDF viewer for c:\Users\Mr Sinamun\Projects\web3\scratch\lalala.pdf
[00:47:26] Parse fls file.
[00:47:27] Preview PDF file: c:\Users\Mr Sinamun\Projects\web3\scratch\lalala.pdf
mainThreadExtensionService.ts:65 [[object Object]]ENOENT: no such file or directory, open 'C:\data\lalala.aux'
$onExtensionRuntimeError @ mainThreadExtensionService.ts:65
_doInvokeHandler @ rpcProtocol.ts:398
_invokeHandler @ rpcProtocol.ts:383
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
(anonymous) @ rpcProtocol.ts:101
fire @ event.ts:581
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
(anonymous) @ ipc.net.ts:592
fire @ event.ts:581
acceptChunk @ ipc.net.ts:239
(anonymous) @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:200
addChunk @ _stream_readable.js:294
readableAddChunk @ _stream_readable.js:275
Readable.push @ _stream_readable.js:210
onStreamRead @ internal/stream_base_commons.js:166
mainThreadExtensionService.ts:66 Error: ENOENT: no such file or directory, open 'C:\data\lalala.aux'
at Object.openSync (fs.js:447:3)
at Object.func (electron/js2c/asar.js:138:31)
at Object.func [as openSync] (electron/js2c/asar.js:138:31)
at Object.readFileSync (fs.js:349:35)
at Object.fs.readFileSync (electron/js2c/asar.js:580:40)
at Object.fs.readFileSync (electron/js2c/asar.js:580:40)
at c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\out\src\components\manager.js:488:38
at Array.forEach (<anonymous>)
at Manager.parseFlsFile (c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\out\src\components\manager.js:486:24)
at Builder.buildFinished (c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\out\src\components\builder.js:337:32)
at ChildProcess.<anonymous> (c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\out\src\components\builder.js:314:30)
at ChildProcess.emit (events.js:200:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
Yes - With Remote Container (aergus/latex)
"latex-workshop.docker.image.latex": "aergus/latex",
"latex-workshop.view.pdf.viewer": "tab"
This is related to https://github.com/nodejs/node/issues/7367. I will look into it.
The complaint about the .aux is something different. Can you post the content of the lalala.fls file?
Looking closely at the logs, I am a bit puzzled by the failure of the formatting command because of spaces in the command path. Building went fine and yet it was using latexmk.bat, which is located at the very same place as latexindent.bat and should suffer from the same issue. In both formatting and building, we simply use cp.spawn to call the appropriate command. So I do not understand what is going wrong.
I do not have access to a Windows machine. Could someone investigate what is going on in this?
The complaint about the
.auxis something different. Can you post the content of thelalala.flsfile?
This is the content of my .fls:
PWD /data
INPUT /etc/texmf/web2c/texmf.cnf
INPUT /usr/share/texmf/web2c/texmf.cnf
INPUT /usr/share/texlive/texmf-dist/web2c/texmf.cnf
INPUT /var/lib/texmf/web2c/pdftex/pdflatex.fmt
INPUT lalala.tex
OUTPUT lalala.log
INPUT /usr/share/texlive/texmf-dist/tex/latex/base/article.cls
INPUT /usr/share/texlive/texmf-dist/tex/latex/base/article.cls
INPUT /usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
INPUT /usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
INPUT lalala.aux
INPUT lalala.aux
OUTPUT lalala.aux
INPUT /usr/share/texlive/texmf-dist/fonts/map/fontname/texfonts.map
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmr17.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmr12.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmmi12.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmmi12.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmsy10.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmsy10.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmr8.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmr6.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmmi8.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmmi6.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmsy8.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmsy6.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmr9.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmbx9.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmr12.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmbx12.tfm
INPUT /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmbx12.tfm
OUTPUT lalala.pdf
INPUT /var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map
INPUT lalala.aux
INPUT /usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb
INPUT /usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx9.pfb
INPUT /usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmex10.pfb
INPUT /usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb
INPUT /usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb
INPUT /usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12.pfb
INPUT /usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr17.pfb
INPUT /usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr9.pfb
Looking closely at the logs, I am a bit puzzled by the failure of the formatting command because of spaces in the command path. Building went fine and yet it was using
latexmk.bat, which is located at the very same place aslatexindent.batand should suffer from the same issue. In both formatting and building, we simply usecp.spawnto call the appropriate command. So I do not understand what is going wrong.I do not have access to a Windows machine. Could someone investigate what is going on in this?
I have moved the project to c:\, but i get the same error:
[17:18:48] Found root file from active editor: c:\web3\scratch\lalala.tex
[17:18:48] Root file remains unchanged from: c:\web3\scratch\lalala.tex.
[17:18:50] Formatting with command c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\scripts\latexindent.bat -c,c:/web3/scratch/,c:/web3/scratch/__latexindent_temp.tex,-y=defaultIndent: ' '
[17:18:50] Formatting failed with exit code 1
[17:18:50] stderr: 'c:\Users\Mr' is not recognized as an internal or external command,
operable program or batch file.
As you said it really is quite puzzling for it to work only in one case.
I am unable to investigate since I have no knowledge of ts and extension debugging, but I can provide logs from different environments with different configurations if that is helpful.
Ok I get it for the .aux issue. The first line of the .fls file says PWD /data but the thing is that /data is actually a directory inside the docker image. We should use the dirname of the .fls file as the working directory to interpret the file paths listed in there.
Can you try to call _SyncTeX from cursor_ from the TeX badge and post the logs?
All these commands rely on cp.spawn. Thanks for your cooperation
Can you try to call _SyncTeX from cursor_ from the TeX badge and post the logs?
All these commands rely oncp.spawn. Thanks for your cooperation
With _"latex-workshop.synctex.synctexjs.enabled": true_:
[10:58:00] SYNCTEX command invoked.
[10:58:01] SyncTeX failed.
[10:58:01] no relevant entry of tex file found in the synctex file.
[10:58:01] SyncTexJsError: no relevant entry of tex file found in the synctex file.
at Object.syncTexJsForward (c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\out\src\components\synctex.js:51:15)
at Locator.syncTeX (c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\out\src\components\locator.js:126:42)
at Commander.synctex (c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\out\src\commander.js:212:32)
at c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\out\src\main.js:63:89
at v._executeContributedCommand (c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:538:925)
at v.$executeContributedCommand (c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:539:295)
at p._doInvokeHandler (c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:663:275)
at p._invokeHandler (c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:662:971)
at p._receiveRequest (c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:661:639)
at p._receiveOneMessage (c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:660:468)
at c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:658:691
at l.fire (c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:46:893)
at _.fire (c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:189:274)
at c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:820:285
at l.fire (c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:46:893)
at _.fire (c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:189:274)
at t.PersistentProtocol._receiveMessage (c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:193:629)
at c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:190:824
at l.fire (c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:46:893)
at p.acceptChunk (c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:186:737)
at c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:186:89
at Socket.t (c:\Users\Mr Sinamun\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:195:68)
at Socket.emit (events.js:200:13)
at addChunk (_stream_readable.js:294:12)
at readableAddChunk (_stream_readable.js:275:11)
at Socket.Readable.push (_stream_readable.js:210:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:166:17)
With _"latex-workshop.synctex.synctexjs.enabled": false_:
[11:22:46] SYNCTEX command invoked.
[11:22:46] Executing synctex with args view,-i,24:16:lalala.tex,-o,lalala.pdf
[11:22:48] Try to synctex c:\Users\Mr Sinamun\Projects\web3\scratch\lalala.pdf
Thanks. The test with "latex-workshop.synctex.synctexjs.enabled": true works fine, which means that cp.spawn is able to run the c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\scripts\synctex.bat and is not bothered by the space.
It took me a while googling around but I hope I get it. This seems related to nodejs/node/issues/7367 stating that the failure only occurs when there is a space both in the command and an argument. Synctex and build take the relative path to the file lalala.tex
Recipe step 1: c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\scripts\latexmk.bat, -synctex=1,-interaction=nonstopmode,-file-line-error,-pdf,-outdir=./,lalala
Executing synctex with args view,-i,24:16:lalala.tex,-o,lalala.pdf
whereas
Formatting with command c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\scripts\latexindent.bat -c,c:/Users/Mr Sinamun/Projects/web3/scratch/,c:/Users/Mr Sinamun/Projects/web3/scratch/__latexindent_temp.tex,-y=defaultIndent: ' '
Yet, I am bit puzzled by this one. Maybe the -y=defaultIndent: ' '
Formatting with command c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\scripts\latexindent.bat -c,c:/web3/scratch/,c:/web3/scratch/__latexindent_temp.tex,-y=defaultIndent: ' '
There is no easy fix mentioned in nodejs/node/issues/7367. The solution might be to use cross-spawn. I can make a PR but unfortunately I won't be able to test because I have no access to a Windows machine. Will you be able to test it, see here for how to?
I've followed your guide and was able to test #1883.
The format command has slightly different output depending on which docker image was used:
aergus/latex
[15:15:46] Formatting with command c:\Users\Mr Sinamun\Projects\LaTeX-Workshop\scripts\latexindent.bat -c,c:/Users/Mr Sinamun/Projects/web3/scratch/,c:/Users/Mr Sinamun/Projects/web3/scratch/__latexindent_temp.tex,-y=defaultIndent: ' '
[15:15:48] Formatting failed with exit code 2
[15:15:48] stderr: Could not find directory c:/Users/Mr Sinamun/Projects/web3/scratch/
Exiting, no indentation done. at /usr/share/texlive/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm line 104.
default: (tianon/latex)
[15:23:16] Formatting with command c:\Users\Mr Sinamun\Projects\LaTeX-Workshop\scripts\latexindent.bat -c,c:/Users/Mr Sinamun/Projects/web3/scratch/,c:/Users/Mr Sinamun/Projects/web3/scratch/__latexindent_temp.tex,-y=defaultIndent: ' '
[15:23:18] Formatting failed with exit code 2
[15:23:18] stderr: Unknown option: y
Could not find directory c:/Users/Mr Sinamun/Projects/web3/scratch/
Exiting, no indentation done. at /usr/bin/latexindent line 141.
The tianon/latex docker image does not support the y option, since it is using latexindent.pl version 2.2. Is this worth it's own issue?
Other commands such as SyncTeX and Build still work.
This is good news! With aergus/latex, the latexindent.bat was indeed launched, which means we have fixed the original issue. The complaint about the missing directory c:/Users/Mr Sinamun/Projects/web3/scratch/ is raised by the Perl code itself. Have you checked that this directory does exist? It looks odd to have c: followed by a path with / instead of \, however Perl has been understanding forward slashes for long.
Can you try to run the formatting command from the command line (directly from directory c:\Users\Mr Sinamun\Projects\LaTeX-Workshop\scripts`)? You need set the environment variable LATEXWORKSHOP_DOCKER_LATEX with the value of latex-workshop.docker.image.latex.
latexindent.bat -c "c:/Users/Mr Sinamun/Projects/web3/scratch/" "c:/Users/Mr Sinamun/Projects/web3/scratch/lalala.tex" -y=defaultIndent:' '
If it fails, can you play a bit with the quotes and / ?
To solve the issue with tianon/latex, you have to edit the configuration variable latex-workshop.latexindent.args.
The current issue seems to be caused by latexindent.bat in conjunction with the %DIR% and %TMPFILE% variables.
When running:
latexindent.bat -c "c:/Users/Mr Sinamun/Projects/web3/scratch/" "c:/Users/Mr Sinamun/Projects/web3/scratch/lalala.tex" -y=defaultIndent:' '
in the directory: c:\Users\Mr Sinamun\Projects\LaTeX-Workshop\scripts
the output is:
C:\Users\Mr Sinamun\Projects\LaTeX-Workshop\scripts>docker run -i --rm -w /data -v "C:\Users\Mr Sinamun\Projects\LaTeX-Workshop\scripts:/data" aergus/latex latexindent -c "c:/Users/Mr Sinamun/Projects/web3/scratch/" "c:/Users/Mr Sinamun/Projects/web3/scratch/lalala.tex" -y=defaultIndent:" "
Could not find directory c:/Users/Mr Sinamun/Projects/web3/scratch/
Exiting, no indentation done. at /usr/share/texlive/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm line 104.
The folder from which latexindent.bat is executed (usually the project directory) is mounted as /data, therefore the arguments for the -c parameter should be -c "/data/" "/data/lalala.tex" and not the project directory path from the windows host.
When I hardcore latex-workshop.latexindent.args as follows:
"latex-workshop.latexindent.args": [
"-c",
"/data/",
"/data/lalala.tex",
"-y=defaultIndent: '%INDENT%'"
],
and run the Format Document on lalala.tex it works:
[19:35:05] Formatting with command c:\Users\Mr Sinamun\Projects\LaTeX-Workshop\scripts\latexindent.bat -c,/data/,/data/lalala.tex,-y=defaultIndent: ' '
[19:35:07] Formatted c:\Users\Mr Sinamun\Projects\web3\scratch\lalala.tex
This does not happen on Linux, because the latexindent script mounts the docker volume as -v "$(pwd):$(pwd)., which makes it possible to use the %DIR% and %TMPFILE% variables without issues.
I think you have found the second problem. Looking closely at your first post
Recipe step 1: c:\Users\Mr Sinamun\.vscode\extensions\james-yu.latex-workshop-8.5.0\scripts\latexmk.bat, -synctex=1,-interaction=nonstopmode,-file-line-error,-pdf,-outdir=./,lalala
The build spawn uses the basename of the rootFile lalala and ./ as output although in the definition of the recipe we use %DOC% and %DIR%. This change is handled by the extension https://github.com/James-Yu/LaTeX-Workshop/blob/9ee65b729bfa159b3636283b575992d671d89f1a/src/components/builder.ts#L500-L515
This is supposed to work similarly for formatting but it does not. I will look into it
I have updated #1883. Can you test it again? The stock configuration should be working fine.
I am waiting for your before merging #1883.
Using #1883, the stock configuration works for formatting!:
[13:08:28] Formatting with command c:\Users\Mr Sinamun\Projects\LaTeX-Workshop\scripts\latexindent.bat -c,.//,__latexindent_temp.tex,-y=defaultIndent: ' '
[13:08:29] Formatted c:\Users\Mr Sinamun\Projects\web3\scratch\lalala.tex
There are two small oddities that I noticed:
c:\Users\Mr Sinamun\Projects\web3\scratch>docker run -i --rm -w /data -v "c:\Users\Mr Sinamun\Projects\web3\scratch:/data" aergus/latex latexindent "-c" ".//" "__latexindent_temp.tex" "-y=defaultIndent: ' '"
\documentclass{article}
\usepackage{graphicx}
\begin{document}
[...]
After running it twice:
c:\Users\Mr Sinamun\Projects\web3\scratch>docker run -i --rm -w /data -v "c:\Users\Mr Sinamun\Projects\web3\scratch:/data" aergus/latex latexindent "-c" ".//" "__latexindent_temp.tex" "-y=defaultIndent: ' '"
c:\Users\Mr Sinamun\Projects\web3\scratch>docker run -i --rm -w /data -v "c:\Users\Mr Sinamun\Projects\web3\scratch:/data" aergus/latex latexindent "-c" ".//" "__latexindent_temp.tex" "-y=defaultIndent: ' '"
\documentclass{article}
\usepackage{graphicx}
\begin{document}
[...]
I realize this is quite the edge-case 馃槄 .
Thank you very much for your work and your time!
Great!!
cmd.exe, see nodejs/node/issues/27120cross-spawn escapes the whole command and its args and uses the shell option of child_process to execute it. There are several "fixes" for this:cms.exe(see herechild_process instead of cross-spawn now that we have fixed placeholders expansion with docker but the problem will undoubtedly reappear.Can you run the following test?
spawn.jscontainingconst cs = require("cross-spawn");
const cp = require("child_process");
const res1 = cs.spawn.sync('t.bat', [], {stdio: 'pipe', cwd: process.cwd()});
console.log(res1.stdout.toString());
const res2 = cs.spawn.sync('echo', ['Hello'], {stdio: 'pipe', cwd: process.cwd()});
console.log(res2.stdout.toString());
const res3 = cp.spawnSync('t.bat', [], {stdio: 'pipe', cwd: process.cwd()});
console.log(res3.stdout.toString());
const res4 = cp.spawnSync('echo', ['Hello'], {stdio: 'pipe', cwd: process.cwd()});
console.log(res4.stdout.toString());
Create a file t.bat containing echo hello
run node spawn.js and post the output
The output is:
C:\Users\Mr Sinamun\Projects\LaTeX-Workshop>echo hello
hello
"Hello"
C:\Users\Mr Sinamun\Projects\LaTeX-Workshop>echo hello
hello
C:\Users\Mr Sinamun\Projects\LaTeX-Workshop\spawn.js:12
console.log(res4.stdout.toString());
^
TypeError: Cannot read property 'toString' of null
at Object.<anonymous> (C:\Users\Mr Sinamun\Projects\LaTeX-Workshop\spawn.js:12:25)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11
The error stack for res4:
Error: spawnSync echo ENOENT
at Object.spawnSync (internal/child_process.js:1041:20)
at Object.spawnSync (child_process.js:607:24)
at Object.<anonymous> (c:\Users\Mr Sinamun\Projects\LaTeX-Workshop\spawn.js:11:17)
at Module._compile (internal/modules/cjs/loader.js:956:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11
Let us forget about res4. I think I have everything I need: executing a .bat file always outputs the command (with both modules). This is probably related to .bat files not being executables and therefore they are executed through cmd.exe which has echo on as default.
I will try to implement a hack in the extension.
To avoid mixing up things. I will merge #1883 and open a new one to fix the echo mode of `cmd.exe.
I will let you know so that you can test it (thanks in advance).
Yes you are right!
By prepending the content of latexindent.bat with an @ the issue with the echoed line is solved:
@docker run -i --rm -w /data -v "%cd%:/data" %LATEXWORKSHOP_DOCKER_LATEX% latexindent %*
I've tested it with aergus/latex and also with a classic TeX Live installation.
Everything should be working fine now. Ask for reopening the issue if not.
Thanks for your cooperation in all the tests.
Thank you for your time. Everything is good now.
Most helpful comment
Everything should be working fine now. Ask for reopening the issue if not.
Thanks for your cooperation in all the tests.