Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have been using LaTeX for about a year now and I am fairly proficient in TextMate. I am currently experimenting with Emacs and AucTeX. I installed the starter kit that Keiran Healy has available. Everything seems to be working fine (all the packages are there and available), but I can't compile the .tex file. I get the following error:

Running `LaTeX' on `test' with ``xelatex --synctex=1 -interaction=nonstopmode "\input" test.tex''
/bin/sh: xelatex: command not found
LaTeX exited abnormally with code 127 at Thu Apr 26 21:02:58

I'm assuming this is probably something simple to fix, but I haven't been able to find a solution searching on here. When I compile the file in Textmate it says it is using pdfTeX. I guess I would like to use that since I've had no problems with it previously. Any help that could get me up and running would be greatly appreciated.

share|improve this question
2  
Is xelatex installed? Are you using a Mac? Is there such a thing as a command line? If, what is the result of typing "xelatex --version"? –  Keks Dose Apr 27 '12 at 8:54
    
I wonder if your path is set correctly for a Bourne shell (/bin/sh). From what I can tell for recent Mac OS's the default shell is bash. –  StrongBad Apr 27 '12 at 10:08
    
I´m beginning to think it might have something to do with this. I followed the instructions @Christian gave below to change the TeX-engine, and it turns out that no matter what I set it to, I get the same error. Ex: Running LaTeX' on test' with ``lualatex --synctex=1 -interaction=nonstopmode "\input" test.tex'' /bin/sh: lualatex: command not found LaTeX exited abnormally with code 127 at Fri Apr 27 05:50:02 How do I go about setting the path for a Bourne shell? Do you think this is the problem even though I have no problems compiling through Textmate? And yes, I am on a Mac (OS X, lion) –  jvcasill Apr 27 '12 at 12:51
    
@KeksDose , the result is: XeTeX 3.1415926-2.3-0.9997.5 (TeX Live 2011) –  jvcasill Apr 27 '12 at 12:55
1  
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. –  doncherry Apr 28 '12 at 8:21
show 1 more comment

4 Answers 4

You can use M-x customize-variable. Then enter TeX-engine and hit enter again. You can then choose from a list of TeX engines and save your choice. If you need to add an entry to the list, this should be possible with the TeX-engine-alist variable. You can find all options here: http://www.gnu.org/software/auctex/manual/auctex/Processor-Options.html

share|improve this answer
4  
Additionally, C-h v TeX-engine will show the current value. –  dbaupp Apr 27 '12 at 9:05
add comment

I had to set the path for Emacs: it was different from the one that was being used from the terminal. What I did was:

  • In Terminal I looked at then value for env (specifically PATH)
  • In Emacs, I typed M-x setenv, variable = PATH
  • I pasted in the same value that I had in terminal and now I can compile with no problems.
share|improve this answer
    
It's very strange that emacs ignores your PATH. Did you start it from the command line or from some kind of launcher? These sometimes don't source your bashrc or whatever shell you use. –  Christian Apr 28 '12 at 13:54
    
I am using Mac OS X and typically launch emacs from spotlight. I have noticed that whenever I close and re-launch emacs I have to go through the process I explained above in order to get the program to compile the document. Otherwise I get the same error I mentioned in the original post. Is it possible to make emacs remember the new path? –  jvcasill Apr 28 '12 at 23:33
1  
Spotlight counts as "some kind of launcher", yes. It's probably more sensible to make Spotlight set up a sensible environment for all apps it launches. This question seems to help there stackoverflow.com/questions/135688/… –  Christian Apr 29 '12 at 20:25
1  
Sorry you ran into this issue—I just had the same problem myself today after updating to 10.7.4 and thought the problem was with my version of the starter kit. But it's not. The problem is as Daniel describes above: the update (or something ...) made GUI Emacs think the shell was /bin/sh and not /bin/bash. The solution, as Christian links to, is to make Spotlight/Launchbar type apps respect the PATH variable in your .bashrc or .bash_profile, as described in the top answer in stackoverflow.com/questions/135688/…. –  Kieran May 14 '12 at 16:28
add comment

If you open a shell inside emacs (M-x shell) then you can check what the PATH variable is in the emacs mind. According to what people are saying above, the problem is that the emacs shell doesn't know about your path. One way of fixing this is to add something to your personal .org file in kjhealy's emacs-starter-kit. You could add:

    *** PATH settings
    Emacs doesn't seem to see the user's choice of PATH, 
    which should be set in .bash_profile, 
    so we have to set the path here.  
    Below is the directory for latex executables in MacTeX-2011.

    #+srcname: path-settings
    #+begin_src emacs-lisp 
      (setenv "PATH" (concat "/usr/local/bin:/usr/texbin:" (getenv "PATH")))
    #+end_src

I would like to know if this is a good way of doing things from the point of view of ESK.

share|improve this answer
add comment

Using Emacs with Mac OS X since years, I came up to use the file $HOME.MacOSX/environment.plist which holds all environment variables I want to set. This file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>LANG</key>
    <string>de_DE.UTF-8</string>
    <key>MM_CHARSET</key>
    <string>UTF-8</string>
    <key>PATH</key>
    <string>/opt/local/bin:/opt/local/sbin:/Applications/Emacs.app/Contents/MacOS/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/texbin:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin:/Developer/Tools:/Users/brf/bin</string>
    <key>PYTHONSTARTUP</key>
    <string>/Users/brf/.pythonrc.py</string>
    <key>PYTHONPATH</key>
    <string>/Users/brf/lib/Python</string>
</dict>
</plist>

Emacs reads this file. Some other programs don't. So I had to read the setting in my .bashrc with is symlinked to .profile. So both files begin like this:

export PATH=$(defaults read "${HOME}/.MacOSX/environment" PATH)
export LANG=$(defaults read "${HOME}/.MacOSX/environment" LANG)
export MM_CHARSET=$(defaults read "${HOME}/.MacOSX/environment" MM_CHARSET)
export PYTHONSTARTUP=$(defaults read "${HOME}/.MacOSX/environment" PYTHONSTARTUP)
export PYTHONPATH=$(defaults read "${HOME}/.MacOSX/environment" PYTHONPATH) 

your settings may differ. The advantage is to set environment variables in one file only. Emacs (I use 23.4.1) opened in any way will find your PATH.

share|improve this answer
    
@AlanMunn No, I have a usual MacTeX, which is TeXLive with TeXShop added. My Emacs is also not from MacPorts. –  Peter Breitfeld Jun 18 '12 at 19:28
    
Fair enough. I've deleted my comment. (Although I stand by the statement that for most users modifying the environment.plist has the potential to cause more problems than it solves.) –  Alan Munn Jun 18 '12 at 20:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.