overleaf / toolkit

GNU Affero General Public License v3.0
596 stars 146 forks source link

Package minted Error: minted v3+ executable is not installed or is not added to PATH #298

Open andreondra opened 1 week ago

andreondra commented 1 week ago

Steps to Reproduce

  1. Install minted package (or full installation) using tlmgr.
  2. Import minted package in a project and insert arbitrary minted environment to a document.

Expected Behaviour

Minted should be successfully invoked and code with syntax highlighting should be printed to the document.

Observed Behaviour

Compiling crashes with error: Package minted Error: minted v3+ executable is not installed or is not added to PATH..

Context

This error is already discussed here: https://github.com/gpoore/minted/issues/401. It seems that apart from upgrading tlmgr packages one should also uninstall minted and install again, which should install required Python dependencies. However, even after doing these steps, latexminted stays on v1:

# latexminted --version
latexminted 0.1.0 (libraries: latex2pydata 0.4.0, pygments 2.18.0)

It looks like system latexminted has precedence on PATH. How can one successfully manage to use latexminted v2? Or probably the problem with minted executable is caused by another problem related to Docker image?

Technical Info

I installed latest toolkit and used docker's shell to install full installation. Shell escape is allowed.

Analysis

EDIT: It looks like it can be fixed by installing latexminted manually via pip3. However, is this OK approach? I thought Python dependencies should be now installed automatically by tlmgr.

d2nt4 commented 6 days ago

Thank you so much for raising this issue and for the solution! I was facing a similar problem with LaTeX and the minted package, and installing latexminted via pip resolved everything. Your contribution really helped me and will certainly assist others who encounter this. For anyone else running into the same issue, make sure to install latexminted if you're having trouble with pygmentize in your LaTeX setup. Thanks again!

andreondra commented 6 days ago

Glad to hear that my fix worked for you! I look forward to any "proper" solution to this problem. For now let's hope this temporary solution didn't break any other packages 😀

derpberk commented 4 days ago

This happened to me aswell. Fixed after upgrading and installing latexminted by:

pip install latexminted

as @andreondra suggested :)

yfilip commented 4 days ago

Thank you for raising the issue and giving a solution. The fix did not work for me. I am using python 3.12.6, MiKTeX and compiling with lualatex. Copying the latexminted.exe that pip installs in the ..\AppData\Local\Programs\Python\Python312\Scripts (this directory is in the PATH) from there to ..\AppData\Local\Programs\MiKTeX\miktex\bin\x64 worked for me. Probably not the best solution.

shalinpather commented 4 days ago

Hi. For some reason, the docs didn't make this clear, but the legacy instructions give it. I had the same issue and days of pain, so I had to post the authoritative solution here.

First, install your packages as such: tlmgr install minted

And then, you must run this command manually: tlmgr path add

This is because all the LaTeX packages you download with tlmgr include the corresponding programs to make them work (in this case, latexminted). However, you must run the command above. It creates symlinks to the binaries to make them available to the system. Once you do this, all installed LaTeX packages will work normally, including Minted, PGF-TiKZ, and other such packages that rely on external programs. This is far better (and wastes far less space) than messing around with pip or the system package manager to download the programs separately and redundantly. You just need to follow these steps.

Don't forget to enable the shell escape to use these programs when you're done!

cx0222 commented 1 day ago

@shalinpather Thank you very much for your comment. However, it seems that this approach doesn't work for me currently. I still encounter the problems as follows:

Package minted Error: minted v3+ executable is not installed or is not added to PATH.

Package minted Error: Missing definition for highlighting style "manni" (minted executable is unavailable or disabled); attempting to substitute fallback style.

Here are the versions:

Could you please kindly help me figure out the issues? Thank you so much.

shalinpather commented 1 day ago

@cx0222 Please show me the contents of the file usr/local/texlive/2024/texmf.cnf. A compilation log might also be helpful. I suspect that if you followed the steps I mentioned, it's probably down to the configuration.

shalinpather commented 1 day ago

@cx0222 Another thing I found is that if you want to install Minted externally using pip, for some reason, you just can't \usepackage{minted}. However, when you change it to \usepackage{minted2}, it works normally. I think the only way to get everything working 100% as the online Overleaf does is to remove any packages you tried installing with the system package manager and pip (or better yet, recreate your sharelatex container) and run tlmgr install <packages> and tlmgr path add. I did this from scratch after deleting the sharelatex container and installing all packages this way (without involving pip or apt-get). Someone else, please confirm this.