gpoore / minted

minted is a LaTeX package that provides syntax highlighting using the Pygments library. Highlighted source code can be customized using fancyvrb.
1.73k stars 125 forks source link

Can not compile via latexmk in Windows #392

Open god464 opened 2 months ago

god464 commented 2 months ago

I'm using Tex Live 2024. This is my .latexmkrc file:

@default_files=('main.tex');
$lualatex='lualatex -shell-escape %O %S';
$jobname='result';
$pdf_mode=4;
$bibtex_use=2;

And I made sure that I already installed pygments[windows-terminal]

When I run latexmk, I will receive this error message:

(e:/texlive/texmf-dist/tex/latex/import/import.sty))
\minted@apppathifexists =

! Package minted Error: You must have `pygmentize' installed to use this package.

See the minted package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.4 \begin{document}

?

But I will not receive this message when I use lualatex --shell-escape main.tex. What should I do?

gpoore commented 2 months ago

It looks like latexmk can't find pygmentize. Are you running latexmk on the command line, or via an editor? My guess is that however it is running, it has a different PATH or environment that doesn't include pygmentize.

god464 commented 2 months ago

Are you running latexmk on the command line, or via an editor?

I ran both of these commands in Powershell instead of the IDE. I have not encountered this problem before (i.e. using Tex Live 2023 and earlier versions).

gpoore commented 2 months ago

That is strange. Have you tried using cmd.exe instead of Powershell? Are you using the very latest latexmk? There was a release of latexmk recently that caused errors for me, but it was quickly followed by a new release that fixed whatever the issue was.

god464 commented 2 months ago

This still does not work in cmd (and gives the same error message). I have made sure that both PowerShell and latexmk are up to date.

gpoore commented 2 months ago

Your .latexmkrc works fine for me under Windows with PowerShell and TeX Live 2024.

I think there must be some sort of configuration issue. You can add code like system('pygmentize -V'); to your .latexmkrc to see whether latexmk can find Pygments, and possibly use similar commands to try to determine what the difference is between PATH in latexmk versus PowerShell.