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.

Comments

british.assassin’s picture

Assigned: british.assassin » Unassigned
kaw3939’s picture

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

kaw3939’s picture

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?

Steven Jones’s picture

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.

kaw3939’s picture

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.

ferfong’s picture

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!

galbarn’s picture

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?

diegofd’s picture

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?

galbarn’s picture

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.

ferfong’s picture

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.

WoodstockBenny’s picture

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

nquocbao’s picture

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"

diegofd’s picture

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.

nobody-2’s picture

Version: 5.x-1.2 » 6.x-1.0-beta1
Assigned: Unassigned » nobody-2

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

imerlin’s picture

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.

golgobot’s picture

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

jrviorato’s picture

I went through an identical problem, drutex couldn't create the png file, and the main reason was because the dvi file wasn't created because the latex command couldn't be run. I did a lot of stuff but i finally made it.

From all the stuff I tried, i think, that the one that works was to run the next two lines of code:

 ~$ texconfig init
~$ texconfig confall

But I am not sure, hope this help.

Note: the lines of code were executed on Linux.

Note2. I also customize the conversion method to use the parameter TEXMFVAR="/[your home dir]/.texmf-var".

gershonavi’s picture

vmunozp -- solution works for me:
first I run
~$ texconfig init
~$ texconfig confall
from shell.

then the custom string is: (and in Image directory I put pull path)

cd [TMP_DIR]; TEXMFVAR="/YOUR_HOME_DIR/.texmf-var" TEXINPUTS="[DRUTEX_DIR]//:" /usr/bin/latex -interaction=batchmode [HASH].tex
/usr/bin/dvipng -o [IMG_FILE] -D [DPI] -T tight -bg Transparent [TMP_DIR]/[HASH].dvi

Avi.

occam98’s picture

Avi,

I've tried all of the commands above and they work perfectly on the command line, but I still get tex embedding fails when I try to run them as a custom string in the preference window of drutex:

Here's my current custom string. Each command between ;'s works perfectly on the command line when I substitute the appropriate variables, however, this command never executes properly in drutex.

cd [TMP_DIR]; TEXMFVAR="~jburk/Sites/sites/default/files/tex/.texmf-var" TEXINPUTS="[DRUTEX_DIR]//:" ; latex -interaction=batchmode [HASH].tex
;dvipng -o [IMG_FILE] -D [DPI] -T tight -bg Transparent [TMP_DIR]/[HASH].dvi

Any ideas as to how to fix this?

Thanks,
-John

jrviorato’s picture

Hi John:

¿is your home directory "~juburk/"?

If it is, i think you should set TEXMFVAR="~jburk/.texmf-var" or preferable, you should use the full home directory path, example:

TEXMFVAR="/home/~jburk/.texmf-var".

Regards
Valentina

monty_hall’s picture

Category: support » bug

I'm having similar problems.

  • I created a directory site/default/files/tex and chown www:www 777.
  • The tmp directory is /tmp with 777.
  • When submitting a page, a notice says "The directory /tmp/drutex-a87ff100def55f81a5626544dd8ef2c1-1 has been created." but there is no such directory on inspection.
  • The http-error.log shows "dvipng: Fatal error, Cannot open output file files/tex/38a238768ba54059df6a5f65c5799b64ce4e1c8c.png"
  • several notices on submit "warning: Parameter 1 to drutex_pdf_nodeapi() expected to be a reference, value given in /usr/local/www/drupal6/sites/all/modules/drutex/drutex.module on line 830."

NOTE: Wikipedia has no problems with the current latex setup(dvi/latex/convert) and it too uses the tmp directory.
Any help appreciated.

hawksjohnd’s picture

@17: This worked for me, going from a fresh apt-get install of texlive on Ubuntu. Thanks for posting your solution!

boclodoa’s picture

Issue tags: +centos, +exec

I had this problem too.

my system is: centos 5.5, php 5.1.6, Apache/2.2.3

pdfeTeX 3.141592-1.21a-2.2 (Web2C 7.5.4) installed with

yum install tetex tetex-fonts tetex-dvips tetex-latex ghostscript

and

yum install ImageMagick

I did many of the things suggested in this issue, and finally got it working (kind of). Here's a list of the things I think could help:

1- put Drutex in Debugging mode (admin/settings/filters/*/configure) and take a look of the warning messages in admin/reports/dblog
2- use "custom" Conversion Method in DruTeX :: LaTeX Renderer in admin/settings/filters/*/configure
3- catch the output of the commands in a textfile. One way to do it is add > /tmp/log.txt (or >> /tmp/log.txt), for example:

cd [TMP_DIR]; TEXINPUTS="[DRUTEX_DIR]//:"  latex  -interaction=batchmode [HASH].tex  > /tmp/log.txt

4- insert some new latex content and check the error messages in the log, maybe

$ cat /tmp/log.txt

5- add informative commands to the "conversion method", for example:

whoami >> /tmp/log.txt
date >> /tmp/log.txt
env >> /tmp/log.txt

at this point I saw, many times:
This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
I can't find the format file `latex.fmt'!

so after googling a while I added other informative commands

kpsewhich   latex.fmt >> /tmp/log.txt
kpsewhich -debug=2  latex.fmt >> /tmp/log.txt
stat -c%A /usr/share/texmf-var/web2c/latex.fmt >> /tmp/log.txt
ls -lha /usr/share/texmf-var/web2c/ >> /tmp/log.txt

with no result.

I really don't know how much helped me, but I think is a good idea to run

$ texconfig init
$ texconfig confall
$ fmtutil-sys --missing

with root but also with the user returned by whoami

after googling again I realized the problem was SELinux, because when I switched to permissive mode

$ setenforce 0

everything worked fine. So, the diagnostic in my case is SELinux is blocking the exec command of PHP, now I'll try to configure SELinux to allow the exec command properly, any help would be verry appreciated.

Note. Other things that can block the exec command (totally or partially) are:
- the disable_functions directive in the php.ini
- the safe mode of PHP

boclodoa’s picture

These commands did the trick

$ chcon -Rv --type=httpd_sys_content_t /usr/share/texmf/
$ chcon -Rv --type=httpd_sys_content_t /usr/share/texmf-var/

now it's working even with the enforcing mode

$ setenforce 1
dwalker51’s picture

Thanks for the help, I got this error too... here is my install docs , it finally worked when I changed the drutex directory permissions to 755 from 666, that I had set for some reason.

Drupal 7 and 7.x-1.x-dev - 2011-Mar-26

drush dl drutex
drush en drutex
yum install texlive texlive-latex
yum install dvipng

Configuration > text formats
add text format called drutext
Set
temporary directory to /tmp
Image DIR to /var/www/html/noao/sites/default/files/drutex
Image URL to sites/default/files/drutex

Conversion method (put in the /usr/bin/s)

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

create those dirs and make RW

mkdir /var/www/html/noao/sites/default/files/drutex
chown -R apache.apache drutex/
chmod 755 drutex/

resolution : 107

Save

Go to configuration > CKEditor

clone from full-html a new profile called drutex