-
-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Equation and Tlkz Preview not working on MacOS #962
Comments
On MacOS 10.13.6 :) |
The temp directory (I think it's a directory which happens to end with |
I am able to make a tex file and run with pdflatex in Is there anything else I can test manually? What other steps are involved? |
@nialltc Hm, strange. This preview thing is very unstable. If you happen to be able to run Kotlin, you could run the following small program, which is pretty much exactly what TeXiFy tries to do, and paste the result here. (If you don't know Kotlin but you want to try, it should not be too difficult to run it with IntelliJ, ask for help if needed) Test programimport java.io.File
import java.io.PrintWriter
import java.nio.file.Paths
import java.util.concurrent.TimeUnit
import javax.imageio.ImageIO
fun main() {
// Test constants
val preamble = """
\pagestyle{empty}
\usepackage{color}
\usepackage{amsmath,amsthm,amssymb,amsfonts}
""".trimIndent()
val previewCode = "\$\\xi\$"
val isWindows = false
val waitTime = 3L
// Actual code
fun runCommand(command: String, args: Array<String>, workDirectory: File): String? {
val executable = Runtime.getRuntime().exec(
arrayOf(command) + args,
null,
workDirectory
)
val (stdout, stderr) = executable.inputStream.bufferedReader().use { stdout ->
executable.errorStream.bufferedReader().use { stderr ->
Pair(stdout.readText(), stderr.readText())
}
}
executable.waitFor(waitTime, TimeUnit.SECONDS)
if (executable.exitValue() != 0) {
println("$command exited with ${executable.exitValue()}\n$stdout\n$stderr")
return null
}
return stdout
}
fun inkscapeExecutable(): String {
var suffix = ""
if (isWindows) {
suffix = ".exe"
}
return "inkscape$suffix"
}
fun pdf2svgExecutable(): String {
var suffix = ""
if (isWindows) {
suffix = ".exe"
}
return "pdf2svg$suffix"
}
fun runPreview(tempDirectory: File) {
val tempBasename = Paths.get(tempDirectory.path.toString(), "temp").toString()
val writer = PrintWriter("$tempBasename.tex", "UTF-8")
val tmpContent = """\documentclass{article}
$preamble
\begin{document}
$previewCode
\end{document}"""
writer.println(tmpContent)
writer.close()
println("Running latex in " + tempDirectory.path)
println(
runCommand(
"pdflatex",
arrayOf(
"-interaction=nonstopmode",
"-halt-on-error",
"$tempBasename.tex"
),
tempDirectory
)
)
println("Running pdf2svg...")
println(
runCommand(
pdf2svgExecutable(),
arrayOf(
"$tempBasename.pdf",
"$tempBasename.svg"
),
tempDirectory
)
)
println("Running inkscape...")
runCommand(
inkscapeExecutable(),
arrayOf(
"$tempBasename.svg",
"--export-area-drawing",
"--export-dpi", "1000",
"--export-background", "#FFFFFF",
"--export-png", "$tempBasename.png"
),
tempDirectory
) ?: throw AccessDeniedException(tempDirectory)
println("Check out the end result in $tempBasename.png")
}
try {
runPreview(createTempDir())
} catch (e: AccessDeniedException) {
println("Trying again in user home dir...")
runPreview(createTempDir(directory = File(System.getProperty("user.home"))))
}
} If not, then I don't really know. There could be many things, maybe Apple doesn't like the dot in the directory name, maybe there is a different permissions problem on /var/folders/bv, or maybe TeXiFy tries to use your home directory (although it seems to fail before that), or something even more complicated. |
@PHPirates that ran ok and was able to view png and pdf after. Here is what is returned.
|
Oh huh, that's strange. But if the problem is not in that code, then where is it? I'm afraid I don't know without actually debugging TeXiFy on your system :/ Can you also maybe try again with the following version of TeXiFy? Maybe it will show more error information. |
Please reopen if you have more information as described in the last post. |
I have the same problem. Could it be that the problem is that it can't find the pdflatex executable, instead of pdflatex not seeing the tmp file? |
@mvdbos Yes, a couple of weeks ago someone helped me debug the issue (#1103), and it seems to be the issue mentioned in #25 (comment) If you know any way in which we could fix this from the plugin, please let us know. We don't have a Mac so we can't reproduce the problem. |
The preview is still not working with 0.7.7-alpha.1 . |
Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
PyCharm 2019.1.3
TeXiFy IDEA version
0.6.6
Inkscape 0.92
pdf2svg 0.2.3
ImageMagick 7.0.8-14
pdflatex: pdfTeX 3.14159265-2.6-1.40.19 (TeX Live 2018), kpathsea version 6.3.0
(All on PATH)
What I did (steps to reproduce)
When I try to preview either and equation or tlkz the preview panel comes up and the code I am trying to preview is recognised but get error
The directory T exists but I don't see that .tmp file.
Many thanks for great plugin
The text was updated successfully, but these errors were encountered: