minted
minted copied to clipboard
Spaces in filenames and outputdir paths cause OS-dependent and option-dependent errors
See https://github.com/gpoore/minted/issues/85#issuecomment-669696829 for original source.
Using filenames with spaces under Linux without outputdir
seems to work fine (produces a correct PDF), but gives catchfile
errors. Using outputdir paths with spaces with outputdir
fails without producing a PDF. Some of this seems to involve ifplatform.sty
running \ShellEsc
around line 94, and quoting a path that is already quoted. outputdir
doesn't auto-quote, so it requires manual quoting, and ifplatform.sty
assumes no quoting. The manual quoting approach is what allows ~
expansion to work.
Windows is different. When there are spaces in the output directory path, outputdir
needs to be quoted. When that is used with -file-line-error
or -recorder
, compilation fails. This is due to some operation that strips spaces from filenames.
It may be impossible to have a solution that works with ifplatform.sty
(assumes no quoting under Linux, wraps with quotes) while also allowing ~
expansion. Alternatives may involve patching ifplatform.sty
or using a different approach to OS detection.
I would add that this problem also occurs under Windows if the filename in braces is not quoted. The error information is
Package minted Error: Missing Pygments output; \inputminted was
probably given a file that does not exist--otherwise, you may need
the outputdir package option, or may be using an incompatible build tool,
or may be using frozencache with a missing file.
Alternatives may involve patching
ifplatform.sty
or using a different approach to OS detection.
The expl3
programming environment provides \sys_if_platform_windows:TF {<true code>} {<false code>}
and similar functions. See one possible emulation in https://github.com/wspr/will2e/issues/12#issuecomment-1724524879.