TeX Embedding failed!

british.assassin - February 10, 2008 - 14:00
Project:DruTeX
Version:6.x-1.0-beta1
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:nobody
Status:active
Description

Hi,

I am having trouble trying to get DruTeX to work. Everytime I try to add an equation to a page I get the following message: "TeX Embedding failed!".

If I go to the input formats and configure the DruTex filter, all the tests at the bottom of the page appear green. I enabled debug mode and got the following error message in the logs:
files/tex/4c0597276a70488fcfe27d7a71a344f950315941.png couldn't be created. Temporary directory was /var/www/virtual/evowebs.co.uk/phptmp/drutex-3adf74d2673f0805dde82726a490ece6-1.

I have chmod both of the phptmp and the files/tex folders to 777, but it still gives this error.

I have tested my latex configuration on my server using the following tex file:

\documentclass[10pt,notitlepage]{article}

% good math support
\usepackage{amsmath, amsfonts, amssymb}

% UTF-8 support
\usepackage{ucs}
\usepackage[utf8x]{inputenc}

\pagestyle{empty}


\begin{document}
\( E=mc^{2} \)
\end{document}

I used the following commands:

latex test.tex
dvipng test.dvi

And this produced the png file correctly.

I am stumped. I would appreciate any help anyone can give.

#1

british.assassin - February 12, 2008 - 21:54
Assigned to:british.assassin» Anonymous

#2

kaw3939 - June 8, 2008 - 05:46

I have the same problem. Any help would be appreciated.

#3

kaw3939 - June 8, 2008 - 08:39

After doing some pulling of hair and teeth. I think that I have the cause of this common module problem. I think that most people run apache as an unprivlaged user that can't call latex and dvipng. This is just a guess.

I run the custom commands manually under my own account and they come through just fine, so I'm thinking it has something to do with how http user is setup on some people's machines. I am setting this up at a university and don't have access to change the permissions for http user, but I may be able to get someone to come up with a workaround.

Any ideas?

#4

Steven Jones - June 9, 2008 - 06:09

I was just about to ask if apache had permission to call latex and dvipng, but then these are both called on the status page, so that should fail too.

If you have terminal access you could sudo over to the apache user and try running latex.

#5

kaw3939 - June 13, 2008 - 03:06

Hi,

I have shell access and can call latex and dvipng from shell. In fact, I can run the exact same commands run by drutex and get output, but when drutex runs the commands it fails.

The sysadmin said that the http user can run both programs too, so i'm stumped. I'd really like to get drutex working because i'm setting up a learning object repository for an engineering school and a lot of faculty use latex, so this would be a great way for them to easily contribute to the repository.

I'm going to give it another shot next monday, since I've had enough of Drupal for the weekend :)

If you have any other suggestions let me know.

#6

ferfong - November 7, 2008 - 20:25

I have the same problem. I've run the commands as the user "apache" and they correctly generate the png with no errors.

However, when actually run from the site, it does not work, no [hash].log/aux/..etc files are ever created. The temp directory only has the tex file.

We found that it was due to selinux; are you all running with selinux enabled as well?
I think the httpd process was not allowed to read the required tex fmt files. Adding a module to allow this:

allow httpd_t tetex_data_t:dir { getattr search };
allow httpd_t tetex_data_t:file { read getattr };

fixed the problem [so far]. Hope this helps anyone else out there, and if anyone else thinks that there is an easier/more secure solution, I would be glad to hear from you.

Thanks!

#7

galbarn - November 15, 2008 - 16:33

I also have the same problem:
after a adding content like $x^2$ and chosing DruTex as the input format
I get "TeX Embedding failed!".

I also get three warning logs after that:

warning DruTeX 11/15/2008 - 09:13
files/tex/7bcf96c74142994f6263cf9f551547c412a8a1f8.png couldn\'t be created. Temporary directory was c:/wamp/tmp/drutex-1db62e6f21de5e14b0cad079ce65c891-1.

warning DruTeX 11/15/2008 - 09:13
Command: dvipng -o files/tex/7bcf96c74142994f6263cf9f551547c412a8a1f8.png -D 107 -T tight c:/wamp/tmp/drutex-1db62e6f21de5e14b0cad079ce65c891-1/7bcf96c74142994f6263cf9f551547c412a8a1f8.dvi
Return value: 1

and :

warning DruTeX 11/15/2008 - 09:13
Command: cd c:/wamp/tmp/drutex-1db62e6f21de5e14b0cad079ce65c891-1; TEXINPUTS="C:\wamp\www\courses\sites\all\modules\drutex//:" latex -interaction=batchmode 7bcf96c74142994f6263cf9f551547c412a8a1f8.tex
Return value: 1

I have windows XP, wamp2 on my own computer and drupal 5.12.
I have all the needed programs (latex etc) installed,
and the configuration tab of the DruTex input format seems fine:

The temporary directory is writable.
The image directory is writable.
Executing "latex" was successful: MiKTeX-pdfTeX 2.7.2808 (1.40.4) (MiKTeX 2.7)
Executing "dvipng" was successful: This is dvipng 1.9 Copyright 2002-2006 Jan-Ake Larsson
Executing "convert" (ImageMagick) was successful: Version: ImageMagick 6.3.7 12/25/07 Q16 http://www.imagemagick.org"

I'm not sure my apache user has the right permissions as kaw3939 (http://drupal.org/node/219979#comment-874332) said, perhaps that's the problem.

any idea?

#8

diegofd - November 19, 2008 - 18:07

I also get "TeX Embedding failed!".
My configuration is IIS, PHP and Miktex 2.7 but I think that it's failing in the same point.

Have you tryed using backslashes instead of slashes in paths?

#9

galbarn - November 20, 2008 - 11:03

how do I do that?
I've tried changing it in the configuration tab of the drutex input format in the base settings tab
(where you write your paths) but it still using forward slashes.

#10

ferfong - November 20, 2008 - 20:50

Hm, galbarn, it does seem like it would be a path/slash issue.

I've noticed my drutex does not actually use the "temporary folder" set in my DruTeX "Base Settings", but instead uses my drupal 'Site Configuration' -> 'File System' temporary directory.

Still, I don't think this is the problem, as my drutex appears to actually have forward slashes / hard-coded in.

In "drutex_render.inc", drutex sets some default variables and it looks like they use a forward slash:

220:  $image_file = "$image_dir/$hash.$image_type";
227: $temporary_dir = _drutex_create_temporary_dir();
252: file_save_data($content, "$temporary_dir/$hash.tex", FILE_EXISTS_REPLACE);

Also, in drutex.module:

function _drutex_create_temporary_dir($format = -1) {
  static $n = 1;
  $dir = drutex_var_get("drutex_dir_temporary_$format") . '/drutex-' . _drutex_secret() . '-' . $n++;
  mkdir($dir);
  return $dir;
}

I don't know if these change depending on how you install for Windows, though, just thought I'd mention it.

#11

WoodstockBenny - December 17, 2008 - 12:14

I was having similar problems. I'm using Linux with Drupal 6.8 and a beta port of Drutex. I tried everything else, but the logs kept looking something like:

Command: cd /tmp/drutex-6d7b7a649e5a9eeb3c34d92f78309376-1; TEXINPUTS="/var/www/html/modules/drutex//:" latex -interaction=batchmode 1a76725a0b485d514cb485b68915f151f5eab4a3.tex
Return value: 127

I needed three things to get this fixed.

1. Create directory where the images would be stored once created (/drupal_root/sites/default/files/tex) with the appropriate permissions.
2. Change the Image Directory/URL Directory to reflect this (as a relative path from /drupal_root/) to sites/default/files/tex
3. Change to LaTeX Render section to custom and put in absolute paths to latex and dvipng, such as /usr/local/bin/latex and /usr/local/bin/dvipng (of course this will depend on how you are converting the images and the location of your latex/dvipng etc.)

It took a while, but I managed to get there in the end.

Cheers,
Ben

#12

nquocbao - February 2, 2009 - 02:28

I got the same problem, all tex are replace with "Tex embed failed". No log message. I just see some message says that "Folder drupal-xxx was created"

#13

diegofd - February 2, 2009 - 17:11

Anybody has Drutex working with Miktex over IIS6.0? I get the "TeX Embedding failed!" error and I think that it's a permissions or slashes errors.

#14

nobody - March 26, 2009 - 06:00
Version:5.x-1.2» 6.x-1.0-beta1
Assigned to:Anonymous» nobody

OK, I had the same problems but I can solved following the steps proposed by WoodstockBenny with some modifications

1. Create directory where the images would be stored once created (/drupal_root/sites/default/files/tex) with the appropriate permissions.
2. Change the Image Directory whit the absolute path (/drupal_root/sites/default/files/tex) and the Image URL Directory with the relative path (sites/default/files/tex)
3. Change to LaTeX Render section to custom and put in absolute paths to latex and dvipng, such as /usr/bin/latex and /usr/bin/dvipng
cd [TMP_DIR]; TEXINPUTS="[DRUTEX_DIR]//:"; /usr/bin/latex -interaction=batchmode [HASH].tex
/usr/bin/dvipng -o [IMG_FILE] -D [DPI] -T tight [TMP_DIR]/[HASH].dvi
4. Run the command: fmtutil-sys --missing

The last step was necessary because for some reason the apache user can not find the format files for LaTex and it is not able to create the file .dvi

My system is running Fedora 9, Drupal 6.10, DuTex 6.x-1.0-beta1 abd pdfTeXk Version 3.141592-1.40.3 (Web2C 7.5.6)

It took me more than a while, but now it is working

good luck

#15

imerlin - June 20, 2009 - 09:42

Experiencing the same problem with Drupal 6.12 and the latest 6.x DruTeX version.

I am using 'sites' for all my custom Drupal files (configuration, modules, themes, etc) and for some reason, the DruTeX module is trying to use my 'drupal/files' directory for some stuff (even though it is not listed in any settings).

After creating a symbolic link from drupal/sites/mydomain.net/files to drupal/files everything works fine.

#16

golgobot - October 2, 2009 - 06:43

Please help. I went through a lot of trouble to install TexLive and dvipng on my server running FedoraCore7. I can run both commands 'latex' and 'dvipng' from root, and any other user, but DruTex continues to say it cannot execute these commands:

The temporary directory is writable.
The image directory is writable.
Executing "latex" failed. Either LaTeX isn't installed or the "latex" executable is not in one of the search paths.
You cannot render high-quality images without LaTeX.
Mimetex maybe an alternative for you. Consult the documentation on how to use Mimetex.
Executing "dvipng" failed. Either dvipng isn't installed or the "dvipng" executable is not in one of the search paths.
You cannot use dvipng for rendering images (check the conversion method above).
Executing "convert" (ImageMagick) failed. Either ImageMagick isn't installed or the "convert" executable is not in one of the search paths.
You cannot use ImageMagick for rendering images (check the conversion method above).

I saw something about apache not having the correct permissions, which could be the case, but I wouldn't know how to fix that issue. TexLive might have been installed incorrectly, although I just followed the install guides. The binaries for tex were installed in a strange directory, but I thought I had included that directory in the global PATH.

I also tried putting in the absolute paths to latex, dvipng and pdflatex like this

cd [TMP_DIR]; TEXINPUTS="[DRUTEX_DIR]//:" /usr/local/texlive/2008/bin/i386-linux/latex -interaction=batchmode [HASH].tex
/usr/local/texlive/2008/bin/i386-linux/dvipng -o [IMG_FILE] -D [DPI] -T tight [TMP_DIR]/[HASH].dvi

That also produced the same results.

I'm really stuck. Any help would be much appreciated.

Thanks

 
 

Drupal is a registered trademark of Dries Buytaert.