I installed AUCTeX through the package interface. This pulled version 11.89 from ELPA. Before that, I was running a version of AUCTeX provided by my operating system (Ubuntu 12.04), which is 11.87. After restarting Emacs to ensure I was using the new version, switching to (La)TeX mode fails with the error

File mode specification error: (invalid-function TeX-auto-add-type)

I have no reference to TeX-auto-add-type in my init file, so what's going on?


Explanation: In version 11.87, TeX-auto-add-type was a function. In version 11.88 (since commit f4d3f2840e8f448a329b223c081bce556eb6ca67, TeX-auto-add-type became a macro. My understanding is that during the installation of the newer version in a live Emacs, the function was loaded, and the byte compiler picked up the function. After restarting Emacs, there was no function, only a macro, but the bytecode refered to the function, hence the error. It's unclear to me whether this is due to a bug in AUCTeX or a lack of robustness in byte compilation in Emacs in general.

Fix: to recompile the bytecode now that the function is no longer present in memory. This can be done by uninstalling the auctex package and reinstalling. Alternatively, remove the bytecode files ~/.emacs.d/elpa/auctex-11.89.1/*.elc (adjust for your AUCTeX version) (open the directory in Dired, % m \.elc RET D yes RET) and recompile them (M-0 M-x byte-recompile-directory — you need the prefix argument 0 to recompile all the files even though the no .elc file is present).

Note: This problem can be avoided by not performing the package installation in a live Emacs, but in a dedicated instance. Generally speaking, performing package installations in an instance of Emacs just for that task is safer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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