James-Yu / LaTeX-Workshop

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

Can't compile in paths with spaces and special characters #3515

Closed snhansen closed 1 year ago

snhansen commented 1 year ago

Describe the bug [Required]

Compilation throws error if .tex-document is inside folder with space and special character.

To Reproduce

Steps to reproduce the behavior:

  1. Compile a .tex-document using (Ctrl+Alt+b) that's in a folder of the type "c:\dir dir\hæ\".
  2. See error.

Expected behavior

Compilation should succeed.

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]

[13:38:38] Initializing LaTeX Workshop.
[13:38:38] Extension root: c:\Users\xxxx\.vscode\extensions\james-yu.latex-workshop-8.29.0
[13:38:38] $PATH: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\ffmpeg\bin\;C:\Program Files\Git\cmd;C:\rtools40\usr\bin;C:\rtools40\mingw64\bin;C:\Program Files (x86)\dotnet\;C:\Program Files\PuTTY\;C:\Users\xxxx\AppData\Local\Programs\Quarto\bin;C:\Users\xxxx\AppData\Local\Microsoft\WindowsApps;C:\Users\xxxx\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\;;C:\Users\xxxx\AppData\Local\Programs\Microsoft VS Code\bin
[13:38:38] $SHELL: undefined
[13:38:38] $LANG: undefined
[13:38:38] $LC_ALL: undefined
[13:38:38] process.platform: win32
[13:38:38] process.arch: x64
[13:38:38] vscode.env.appName: Visual Studio Code
[13:38:38] vscode.env.remoteName: undefined
[13:38:38] vscode.env.uiKind: 1
[13:38:38] Configuration for workspace: undefined
[13:38:38] editor.acceptSuggestionOnEnter: "on"
[13:38:38] latex-workshop.bind.enter.key: true
[13:38:38] latex-workshop.docker.enabled: false
[13:38:38] latex-workshop.docker.image.latex: ""
[13:38:38] latex-workshop.hover.preview.mathjax.extensions: []
[13:38:38] latex-workshop.intellisense.package.enabled: true
[13:38:38] latex-workshop.intellisense.update.aggressive.enabled: false
[13:38:38] latex-workshop.intellisense.update.delay: 1000
[13:38:38] latex-workshop.latex.autoBuild.run: "onFileChange"
[13:38:38] latex-workshop.latex.build.forceRecipeUsage: true
[13:38:38] latex-workshop.latex.outDir: "%DIR%"
[13:38:38] 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"
  ]
 }
]
[13:38:38] 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": {}
 }
]
[13:38:38] latex-workshop.viewer.pdf.internal.keyboardEvent: "auto"
[13:38:38] Creating a new file watcher.
[13:38:38] watcherOptions: {"useFsEvents":false,"usePolling":false,"interval":300,"binaryInterval":1000,"awaitWriteFinish":{"stabilityThreshold":250}}
[13:38:38] Creating PDF file watcher.
[13:38:38] watcherOptions: {"useFsEvents":false,"usePolling":false,"interval":300,"binaryInterval":1000,"awaitWriteFinish":{}}
[13:38:38] Creating Bib file watcher.
[13:38:38] watcherOptions: {"useFsEvents":false,"usePolling":false,"interval":300,"binaryInterval":1000,"awaitWriteFinish":{"stabilityThreshold":250}}
[13:38:38] Set $LATEXWORKSHOP_DOCKER_LATEX: ""
[13:38:39] pdflatex is provided by MiKTeX
[13:38:39] [Server] Creating LaTeX Workshop http and websocket server.
[13:38:39] LaTeX Workshop initialized.
[13:38:39] Trigger characters for intellisense of LaTeX documents: ["\\",",","{"]
[13:38:39] Bibtex format config: {"tab":"  ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]}
[13:38:39] Current workspace folders: undefined
[13:38:39] Found root file from active editor: u:\dir dir\hæ\test.tex
[13:38:39] Root file changed: from undefined to u:\dir dir\hæ\test.tex
[13:38:39] Start to find all dependencies.
[13:38:39] Root file languageId: latex
[13:38:39] [Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":54838}
[13:38:39] Reset file watcher.
[13:38:39] Parsing a file and its subfiles: u:\dir dir\hæ\test.tex
[13:38:39] Parse fls file.
[13:38:39] Cannot find fls file: u:\dir dir\hæ\test.fls
[13:38:39] Added to file watcher: u:\dir dir\hæ\test.tex
[13:38:39] Snippet data loaded.
[13:38:39] [Server] valdOrigin is http://127.0.0.1:54838
[13:38:39] Checking for duplicate labels: u:\dir dir\hæ\test.tex.
[13:38:41] Manager.fileWatcher.getWatched: {"u:\\dir dir\\hæ":["test.tex"]}
[13:38:41] Manager.filesWatched: ["u:\\dir dir\\hæ\\test.tex"]
[13:38:41] BibWatcher.bibWatcher.getWatched: {}
[13:38:41] BibWatcher.bibsWatched: []
[13:38:41] PdfWatcher.pdfWatcher.getWatched: {}
[13:38:41] PdfWatcher.pdfsWatched: []
[13:38:41] PdfWatcher.watchedPdfVirtualUris: []
[13:38:41] PdfWatcher.ignoredPdfUris: []
[13:38:45] BUILD command invoked.
[13:38:45] The document of the active editor: file:///u:/dir dir/hæ/test.tex
[13:38:45] The languageId of the document: latex
[13:38:45] Current workspace folders: undefined
[13:38:45] Found root file from active editor: u:\dir dir\hæ\test.tex
[13:38:45] Keep using the same root file: u:\dir dir\hæ\test.tex
[13:38:45] Building root file: u:\dir dir\hæ\test.tex
[13:38:45] Build root file u:\dir dir\hæ\test.tex
[13:38:45] outDir: u:/dir dir/hæ
[13:38:45] Recipe step 1: latexmk
[13:38:45] Recipe step 1 args: ["--max-print-line=10000","-synctex=1","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=u:/dir dir/hæ","u:/dir dir/hæ/test"]
[13:38:45] Recipe step env: {}
[13:38:45] cwd: u:\dir dir\hæ
[13:38:45] LaTeX build process spawned. PID: 5200.
[13:38:47] Recipe returns with error: 11/null. PID: 5200. message: C:\Users\xxxx\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\kpsewhich.exe: unrecognized option `-outdir=u:/dir'

------------
Latexmk: Could not find file '-outdir=u:/dir dir/hæ'.
-- Use the -f option to force complete processing.
.
[13:38:47] The environment variable $PATH: undefined
[13:38:47] The environment variable $Path: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\ffmpeg\bin\;C:\Program Files\Git\cmd;C:\rtools40\usr\bin;C:\rtools40\mingw64\bin;C:\Program Files (x86)\dotnet\;C:\Program Files\PuTTY\;C:\Users\xxxx\AppData\Local\Programs\Quarto\bin;C:\Users\xxxx\AppData\Local\Microsoft\WindowsApps;C:\Users\xxxx\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\;;C:\Users\xxxx\AppData\Local\Programs\Microsoft VS Code\bin
[13:38:47] The environment variable $SHELL: undefined
[13:38:47] Cleaning auxiliary files and retrying build after toolchain error.
[13:38:47] Clean glob matched files: {"globs":["*.aux","*.bbl","*.blg","*.idx","*.ind","*.lof","*.lot","*.out","*.toc","*.acn","*.acr","*.alg","*.glg","*.glo","*.gls","*.fls","*.log","*.fdb_latexmk","*.snm","*.synctex(busy)","*.synctex.gz(busy)","*.nav","*.vrb"],"outdir":"u:\\dir dir\\hæ"}
[13:38:47] Ignore folder glob patterns with globstar: 
[13:38:47] Recipe step 1: latexmk
[13:38:47] Recipe step 1 args: ["--max-print-line=10000","-synctex=1","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=u:/dir dir/hæ","u:/dir dir/hæ/test"]
[13:38:47] Recipe step env: {}
[13:38:47] cwd: u:\dir dir\hæ
[13:38:47] LaTeX build process spawned. PID: 22160.
[13:38:48] Recipe returns with error: 11/null. PID: 22160. message: C:\Users\xxxx\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\kpsewhich.exe: unrecognized option `-outdir=u:/dir'

------------
Latexmk: Could not find file '-outdir=u:/dir dir/hæ'.
-- Use the -f option to force complete processing.
.
[13:38:48] The environment variable $PATH: undefined
[13:38:48] The environment variable $Path: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\ffmpeg\bin\;C:\Program Files\Git\cmd;C:\rtools40\usr\bin;C:\rtools40\mingw64\bin;C:\Program Files (x86)\dotnet\;C:\Program Files\PuTTY\;C:\Users\xxxx\AppData\Local\Programs\Quarto\bin;C:\Users\xxxx\AppData\Local\Microsoft\WindowsApps;C:\Users\xxxx\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\;;C:\Users\xxxx\AppData\Local\Programs\Microsoft VS Code\bin
[13:38:48] The environment variable $SHELL: undefined
[13:39:21] LOG command invoked: default
[13:39:25] LOG command invoked: default
[13:39:27] LOG command invoked: default
[13:39:29] LOG command invoked: compiler
[13:39:29] Current workspace folders: undefined
[13:39:29] Found root file from active editor: u:\dir dir\hæ\test.tex
[13:39:29] Keep using the same root file: u:\dir dir\hæ\test.tex
[13:39:29] LOG command invoked: default
[13:39:29] Current workspace folders: undefined
[13:39:29] Found root file from active editor: u:\dir dir\hæ\test.tex
[13:39:29] Keep using the same root file: u:\dir dir\hæ\test.tex

Developer Tools Console [Required]

Recipe terminated with error.
onDidChangeNotification @ notificationsAlerts.ts:42

Desktop [Required]

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

Additional context

In the terminal all the following works: latexmk -pdf -outdir="u:/hæ" test.tex latexmk -pdf -outdir="u:/dir dir" test.tex latexmk -pdf -outdir="u:/dir dir/yep" test.tex

but latexmk -pdf -outdir="u:/dir dir/hæ" test.tex throws an error:

Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 17 Mar. 2022. Version 4.77, version: 4.77.
Latexmk: Removed (balanced quotes) from filename '"-outdir=u:/dir dir/hæ"',
   and obtained '-outdir=u:/dir dir/hæ'.
C:\Users\xx\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\kpsewhich.exe: unrecognized option `-outdir=u:/dir'

------------
Latexmk: Could not find file '-outdir=u:/dir dir/hæ'.
-- Use the -f option to force complete processing.
jlelong commented 1 year ago

I cannot reproduce the issue with texlive on OSX. If running latexmk -pdf -outdir="u:/dir dir/hæ" test.tex from the terminal fails, then it is not related to the extension but rather to latexmk and/or miktex.

snhansen commented 1 year ago

Hm, weird. But yes, it appears to be a latexmk thing rather than this extension. Sorry about that. I should try and re-install MiKTeX but for now I fixed it by excluding the "-outdir=%OUTDIR%" option in latex-workshop.latex.tools["latexmk"].