Problem :
I have an application (Exuberant Ctags) installed in /usr/bin.
I have also compiled Emacs from source, which installs its own version of ctags in /usr/local/bin.
Running ctags from the command prompt runs the Emacs version from /usr/local/bin.
Is there a way to force it use the application from /usr/bin?
I can go into /usr/local/bin and delete or rename the unwanted ctags version, but I am wondering if there is another way.
Solution :
Edit your PATH, so /usr/bin appears before /usr/local/bin. You find out your current path with echo $PATH
. To change this depends on your system, usually ~/.bashrc
. There are questions here and on ServerFault dealing with where to find environment variables and which to use, ~/.bashrc
or ~/.bash_profile
🙂
If you do have software installed in /usr/local/bin/
that “overrides” what the system put in /usr/bin
, you can create an alias to specify which executable to run on a per-program basis. For example with this ctags program, put this in your ~/.bashrc
.
alias ctags="/usr/bin/ctags"
(though one of the SF links was about cygwin specifically, it is applicable on other platforms as well)
If you don’t need a ctags
installation in /usr/local
, just delete it. (This is the best way possible ‘cuz it’ll save you from having to work around the problem that you’re having now, ever again.)
Or prevent Emacs from installing it in the first place and/or make it check for an existing one before installing (how to do that depends on how you’re installing it).
Finally, you can tell Emacs the path to ctags
as per EmacsWiki: Build Tags, by placing
(setq path-to-ctags "<path_to_ctags_executable>")
into your init file.