KcFnMi - 1 year ago 153
LaTeX Question

# Sublime Text Build LaTex, issue with minted package

Minted is used add beauty to code in LaTex, like in:

\documentclass{article}
\usepackage{minted}
\begin{document}
\begin{minted}{c}
int main() {
printf("hello, world");
return 0;
}
\end{minted}
\end{document}


I've installed it and it works fine if I call, from the command line:

pdflatex -shell-escape minimal.tex


But I'm using Sublime Text Build System to make the PDF, here is the build script:

{
"cmd": ["/Library/TeX/texbin/pdflatex","-shell-escape","$file"], "selector": "text.tex.latex" }  For some reason when I hit Ctrl+B , it doesn't work as in the Terminal. In the output panel I see: This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex) \write18 enabled. entering extended mode (/Users/user/Downloads/minted/minimal.tex LaTeX2e <2016/03/31> Babel <3.9r> and hyphenation patterns for 83 language(s) loaded. (/usr/local/texlive/2016/texmf-dist/tex/latex/base/article.cls Document Class: article 2014/09/29 v1.4h Standard LaTeX document class (/usr/local/texlive/2016/texmf-dist/tex/latex/base/size10.clo)) (/usr/local/texlive/2016/texmf-dist/tex/latex/minted/minted.sty (/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2016/texmf-dist/tex/latex/oberdiek/kvoptions.sty (/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/ltxcmds.sty) (/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty (/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/infwarerr.sty) (/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/etexcmds.sty (/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/ifluatex.sty)))) (/usr/local/texlive/2016/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty Style option: fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix <2008/02/07> (tvz)) (/usr/local/texlive/2016/texmf-dist/tex/latex/float/float.sty) (/usr/local/texlive/2016/texmf-dist/tex/latex/base/ifthen.sty) (/usr/local/texlive/2016/texmf-dist/tex/latex/tools/calc.sty) (/usr/local/texlive/2016/texmf-dist/tex/latex/ifplatform/ifplatform.sty (/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty (/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/ifpdf.sty)) (/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/catchfile.sty) (./minimal.w18)) (/usr/local/texlive/2016/texmf-dist/tex/latex/etoolbox/etoolbox.sty) (/usr/local/texlive/2016/texmf-dist/tex/generic/xstring/xstring.sty (/usr/local/texlive/2016/texmf-dist/tex/generic/xstring/xstring.tex)) (/usr/local/texlive/2016/texmf-dist/tex/latex/lineno/lineno.sty)) (./_minted-minimal/default.pygstyle)system returned with code 256 ! Package minted Error: You must have pygmentize' installed to use this packag e. See the minted package documentation for explanation. Type H <return> for immediate help. ... l.3 \begin{document} ?  Why pygmentize isn't found via Sublime Text? Answer Source As much as I love OS X - this whole path story is just a pain and at least to me it seems that it changes again in every major release. Now, when launching Sublime Text, it inherits the $PATH variable (which basically tells Sublime Text where it should look for external programs like pdflatex or pygmentize) from the launchctl tool - and not from the shell. Thus, even if everything works perfectly fine in a shell, it won't work from Sublime Text (or most other editors).

You can try to fix this yourself, as described in this question on AskDifferent.SE. This has the advantage that it "fixes" the path for all applications, i.e. even if you switch to another editor. To do that, you will have to add the following to your .bash_profile :

export PATH=some_path:another_path
launchctl setenv PATH \$PATH


Taken from this answer

Note, you probably won't need the first line, if everything works in the terminal. Just make sure to call launchctl after setting all paths.

Another possibility, if you prefer a Sublime Text way, is to use the SublimeFixMacPath plugin for Sublime Text 2 or 3, which adds all paths from your shell to the Sublime Text path. That way, anything that works in the shell also works in Sublime Text.