I'm trying to install and configure the ggtags package. Primarily, I use it for a ruby on rails projects (enh-ruby-mode).

I can generate ctags including all vendor's files for my project with the following command:

ctags -R --languages=ruby --exclude=.git --exclude=log . $(bundle list --paths)

How can I configure ggtags package to achieve the same thing?

I use OS X, with installed exuberant-ctags and pygments plugins.

I think, I need to add some settings to ~/.globalrc or to the project root's gtags.conf, but I don't know the settings.

  • I think you might just need to build global with ctags as its backend. With that ctags will go the parsing but global will save the database in its more efficient manner. Once you get that working from the terminal, ggtags package will also work the same way. With that, this might not be an emacs related question at all. Commented Aug 3, 2015 at 11:31
  • The question is how can I make gtags to run ctags with custom arguments? Can I configure it in .globalrc
    – Kukunin
    Commented Aug 4, 2015 at 11:35
  • I simply have a ~/.ctags for ctags config and ~/.globalrc for global config. You need to specify the ctags binary location when building global: gnu.org/software/global/globaldoc_toc.html#Plug_002din Commented Aug 4, 2015 at 12:32

2 Answers 2


Here's how to use global installed from a Ubuntu repository. The version I've had in 6.6.3-2.

First, copy the example config to your home directory. A commentary at its top makes it seem like this is unnecessary, but that's not true. The default config it has is much different, and doesn't recognize .rb files at all, AFAICT.

cat /usr/share/doc/global/examples/gtags.conf.gz | gzip -d >~/.globalrc

Second, you need to choose the underlying mechanism. Pygments sounds great, but it generates "other symbol" entries, not definitions, which is what we normally need.

universal-ctags might be the best choice, but the version of Global seems to need recompiling to use it (either the apt or the snap version). exuberant-ctags works out of the box, though. The ancient version 5.9~svn20110310-1.

Now, as explained in the documentation and in this issue, you would normally need to run gtags --gtagslabel= in every gem directory:

for d in $(bundle list --paths); do
    if [ -d $d ]; then
        echo "$d";
        (cd $d && find . -type f -name "*.rb" | gtags --gtagslabel=ctags -f -)

The use of find here is to avoid including JS files, etc, mostly because of the minified assets. But you can create a smarter enumeration.

To use the indexes from all these directories you need to set the env var GTAGSLIBPATH to the appropriate value during an Emacs session. Given that it's different for every project, and even changes over time, maybe the best approach is to manually call a command in the project directory that will do that for you. Here's one you can use:

(defun set-gtagslibpath-to-bundle-paths ()
  (let ((paths
            (process-file-shell-command "bundle list --paths" nil
    (while (and paths
                (string-match-p "\\`The dependency'" (car paths)))
      (setq paths (cdr paths)))
    (setenv "GTAGSLIBPATH"
            (mapconcat #'identity paths ":"))))

You can also generate the tags with the following command to command to be read by ggtags

gtags --gtagslabel=ctags

The above command should be helpful of any language not supported by gtags but supported by ctags.

  • What if it doesn't work? Does gtags need to be compiled in a particular way to benefit from ctags?
    – Dmitry
    Commented May 8, 2019 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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