[Tex/LaTex] dot2tex conversion failing

conversiondot2tex

I'm having some trouble using the dot2texi package. I'm using the Sublime Text 2 editor to compile my LaTeX files, and I have LaTeXTools installed. I'm running this on Mac OSX, Mountain Lion.

The problem is simply that the dot conversion to tex is failing. I have all necessary packages installed, and if I manually run dot2tex from command line, it produces the figure all well and fine. So I'm guessing this is some problem from the Sublime end? I did a debug log output, and here's the relevant snippet from the log:

\openout3 = `test_latex-dot2tex-fig1.dot'.

Opening dot2tex stream test_latex-dot2tex-fig1.dot
runsystem(dot2tex --figonly -ftikz     --debug --prog=neato -tmath  -o test_lat
ex-dot2tex-fig1.tex  test_latex-dot2tex-fig1.dot)...executed.

Package dot2texi Warning: Conversion of test_latex-dot2tex-fig1.dot failed..

Package dot2texi Warning: Please convert test_latex-dot2tex-fig1.dot manually.

The LaTeX code I'm trying to compile is the simple example from the tutorial:

\documentclass{article}
\usepackage[debug]{dot2texi}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\begin{dot2tex}[neato,mathmode]
digraph G {
node [shape="circle"];
a_1 -> a_2 -> a_3 -> a_4 -> a_1;
}
\end{dot2tex}
\end{document}

Earlier, I had enabled -shell-escape in my LaTeXTools build file, and debugged some _nocomma error out from running dot2tex (Python related). After all those issues were resolved, I could compile dot files from command line using dot2tex without any issues. I can't figure out why it fails in Sublime Text 2 and would like to resolve this for ease-of-use purposes. Any help would be greatly appreciated! Thanks!

P.S. I have an inkling it might be something to do with the command being run from the wrong directory, so it can't find the dot file… I have no idea how to confirm that or fix it.

Best Answer

Ah I finally found the answer, thanks to the Readme over at master builder. The problem description and solution can be found under the Troubleshooting > Path Issues section. For convenience, I'll copy-paste the relevant portion here:

On Mac OS X, just having your $PATH set up correctly in a shell (i.e., in Terminal) does not guarantee that things will work when you invoke commands from ST. If something seems to work when you invoke pdflatex or latexmk from the Terminal, but building from within ST fails, you most likely have a path configuration issue. One way to test this is to launch ST from the Terminal, typing

/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl

(and then Return; this is for ST2 of course) at the prompt. If things do work when you run ST this way, but they fail if you launch ST from the Dock or the Finder, then there is a path problem. From the Terminal, type

echo $PATH

and take note of what you get. Then, run ST from the Dock or Finder, open the console (with Ctrl+ `) and type

import os; os.environ['PATH']

and again take note of what you see in the output panel (right above the line where you typed the above command). Finally, look at the path keyword in the osx section of the LaTeX.sublime-build file in the LaTeXTools package directory. For things to work, every directory that you see listed from the Terminal must be either in the list displayed when you type the import os... command in the ST console, or else it must be explicitly specified in LaTeX.sublime-build. If this is not the case, add the relevant paths in LaTeX.sublime-build and please let me know, so I can decide whether to add the path specification to the default build file. Thanks!

This worked like a charm for me, all I had to do was replace whatever was after the "path": declaration with the shell output from echo $PATH. Hope that helps anyone having this problem.

Related Question