[TxMt] Bibliography Completion Broken?
Charilaos Skiadas
skiadas at hanover.edu
Wed Nov 22 17:56:01 UTC 2006
On Nov 22, 2006, at 12:19 PM, Mark Eli Kalderon wrote:
> Not sure if this has anything to do with the recent update, but the
> bibliography completion command seems to be broken. Neither the key
> command nor calling it from the LaTeX bundle menu seems to work.
> Pretty sure that I haven't done anything to break it since I have
> been too busy to play with TM lately ;). Best, Mark
I made a change that was essential, because I was using a heuristic
that was wrong. The problem is the following:
(This is a bit long an technical. If you get lost, make sure to read
toward the end, for what you have to do to fix this).
The LaTeX installer needs to alter the PATH variable, by appending
the correct path to the LaTeX executables, like for instance
kpsewhich, which is the program used in these completion commands.
The main question now is where this change in the PATH will take
place. The i-installer changes /etc/profile in order to do that, with
something like:
if [ `whoami` != "root" ]
then
PATH="$PATH:/usr/local/teTeX/bin/powerpc-apple-darwin-current"
export PATH
fi
Now, the problem is that /etc/profile only gets executed when a shell
is loaded, like when you open a Terminal window. Hence, when working
from the command line, the value of the PATH variable, which you can
see by doing something like "echo $PATH", would be something like:
/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/teTeX/bin/powerpc-apple-
darwin-current:/usr/local/bin
Or some small variation of it. This way, all LaTeX commands executed
from the command line get to use this path.
Now comes the tricky part, in that all GUI applications, TexShop and
TextMate included, don't get to use anything set in /etc/profile, so
they don't get to use the above path by default, but rather the path
that exists at login time, which is just: /bin:/sbin:/usr/bin:/usr/sbin
This is why the executables in TeXShop need to be specified with
their full path, instead of just the executable name. In TextMate,
you don't see the same problem when executing the LaTeX & View
command, because of some TextMate technicalities: That command does
not start with a shebang (#!), and so is a plain shell script, but
with one important difference: TextMate does a lot of initial work
setting things up for this script. Among those things is taking care
of using the things defined in /etc/profile. However, for all
commands that use a shebang, in particular all Ruby commands that
need the shebang to tell TextMate to use the Ruby interpreter (with a
line like #!/usr/bin/env ruby), this extra work does not take place.
This may change in future version of TextMate, but it is how things
are atm.
Which brings us to the two completion commands, bibliography
completion, and label completion. They both need to somehow find
this path out. It is a bad idea to just execute /etc/profile within
the script, because /etc/profile might be doing all sorts of other
things as well, that might have unfortunate side-effects. The
workaround I had put in place was to use the command line tool
"locate" to find the path to kpsewhich. This was a horrible idea in
the case of multiple TeX installs, in particular if there are both
intel and ppc binaries. So I removed this check, which exposed the
previous problem.
(Here is where you should start reading again if you skipped some of
the above)
The fix is the following: You need to edit a file called ~/.MacOSX/
environment.plist and to add the full path there. This is a file that
is used by all GUI apps, and you can set there values for environment
variables that you want all GUI apps to use. In particular we will
want to add the current path to this file. Start by going to the
terminal and running:
echo $PATH
The result you see printed out is the path we want to use, so select
it and copy. Then see if you have a file called ~/.MacOSX/
environment.plist. For that, again in the command line, you would do:
ls ~/.MacOSX/environment.plist
And if you get something back, then you have the file.
In either case, you should open this file for editing in TextMate. If
you have already installed the command line tool "mate" (Found in
TextMate under Help -> Terminal Usage…, I strongly recommend doing
this), then you would at this point do:
mate ~/.MacOSX/environment.plist
This will open this file in TextMate for editing, or create a new
file if there isn't such a file. If this is a new file, then make its
contents be:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://
www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PATH</key>
<string>/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/teTeX/bin/powerpc-
apple-darwin-current</string>
</dict>
</plist>
where instead of /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/teTeX/bin/
powerpc-apple-darwin-current you should paste whatever value you
copied, that you got from the "echo $PATH"
If you already have such a file, then you need to add the pair:
<key>PATH</key>
<string>/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/teTeX/bin/powerpc-
apple-darwin-current</string>
So what all this does is it sets the value for the PATH variable in a
place that all GUI apps can use. If you later install a different
LaTeX version, then you will need to change this file again.
After saving this file and restarting TM, things should start working
out. You may need to log out and back in, though I don't think so.
Let me know if you still have problems.
Haris
More information about the textmate
mailing list