Tell me more ×
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’m trying to call textoc from OS X Application Alfred as a shell script.

alfred window

And with Alfred everything seems fine—I already asked the developers but they say that the script should work. When debugging I get the message

21.9.11 17:14:12
[0x0-0x40040].com.alfredapp.Alfred[977]
env: texlua: No such file or directory

therefore I guess it’s a problem with texdoc and not with Alfred. I get the same error if I call texdoc with an apple script

do shell script "texdoc file"

But when calling texdoc file directly in my Terminal or in not-silent mode of Alfred (which means a terminal window opens and the command is executed) everything works. A shell script (td.sh)

#!/bin/bash
texdoc $1

called with sh td.sh file works too.

Hope that anyone has an idea how to solve this or at least point where I can get help …

share|improve this question
2  
I guess that the default shell doesn't know about the correct path to the binaries. On my system, osascript -e 'do shell script "texdoc amsmath"' does what's expected. What's the answer to osascript -e 'do shell script "echo $PATH"' given to the terminal? – egreg Sep 21 '11 at 16:09
@egreg: Mille grazie! That leads me to the solution. If you post your text as an answer I’d upvote and accept it :-) – Tobi Sep 21 '11 at 16:28

2 Answers

up vote 4 down vote accepted

It's quite strange, with MacTeX, that the default shell, which is called when a shell script is executed via AppleScript, doesn't have /opt/texbin/ in the PATH variable.

It depends on the version of Mac OS X you're running. On Mac OS X 10.5 and 10.6, there should be a file called TeX in /etc/paths.d/, containing just the line

/usr/texbin

If it's not there, then something has gone wrong with your installation of MacTeX. It's quite easy to correct the behavior: do the following from a terminal window

echo /usr/texbin > TeX
sudo mv TeX /etc/paths.d

and a logoff-login cycle should bring the system into shape. However I don't have a 10.7 machine available, so if your system version is this one, wait for comments.

Check also that a file TeX is present also in /etc/manpaths.d/; if not,

echo /Library/TeX/Distributions/.DefaultTeX/Contents/Man > TeX
sudo mv TeX /etc/manpaths.d

is needed in order to access to the man pages for the TeX programs.

share|improve this answer
I got both files. My TeX system works fine I guess, but texdoc is only available form Alfred if I add the PATH to the script. And in TeXmakerx I need to write "/usr/texbin/latex" instead of latex to make it work. But then everything works fine. – Tobi Sep 21 '11 at 19:22

Here you can get the extension

texdoc-alfred-icon
alfred-td.zip

Just unzip and drop to Alfred’s extension window.
Note that it only works with Alfred’s Powerpack (£12).
Disclaimer: I’m not associated with the application. I’m just a convinced user, who build an extension.

With egregs comment I found out Alfred uses not the full path. echo $PATH gives

/usr/bin:/bin:/usr/sbin:/sbin

in Alfred but

/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:
/Library/Frameworks/Python.framework/Versions/3.1/bin:
/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:
/usr/texbin:/usr/local/bin

in Terminal so changed the Alfred script to

#!/bin/bash
PATH="$PATH:/usr/texbin"
/usr/texbin/texdoc {query}

and it works fine now.

Edit
I shortend the code of PATH=.

share|improve this answer
Do you use TeXLive or MacTeX? – Marco Daniel Sep 21 '11 at 16:52
@Marco: Both I guess. I installed MacTeX but this is TeX Live (with some extras) for OS X I think … – Tobi Sep 21 '11 at 17:40
With MacTeX I have an other path. – Marco Daniel Sep 21 '11 at 18:24
@Marco: Hm … maybe you got another Version of MacTeX or OS X. Mine is TL 2011 an OS X 10.6. And I’m sure that I installed TeX via MacTeX … Note that the $PATH is global and not only for TeX, I guess TeX adds only the /usr/texbin/ part. – Tobi Sep 21 '11 at 19:30

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.