Alex Biddle     About     Archive     Feed

Gtags exclude directory

GNU Global is a source code tagging system that has excellent integration with Emacs, using the ggtags package.

To generate the tags themselves, you run a program called gtags on a top level directory:

$ gtags -v 

Unfortunately, however, on a project that included a particularly large library, gtags failed with the following error:

input buffer overflow, can't enlarge buffer because scanner uses REJECT
gtags: command failed in xargs_read().

I wasn’t particularly interested in browsing the source code for the framework (which had good API documentation), so thought a quick workaround would be to exclude that directory altogether. Unfortunately, a quick hunt around in

man gtags

didn’t produce any command line switch. You have to instead create a config file that lives in .globalrc. This has to be in a specific format and a Google search leads to the config file in the Git repository, so you can download and copy that. The section you want to change is


Note the the trailing slash.

Now running

gtags -v 

in the top level directory skips the large library and produces tags for the rest of the code. It doesn’t fix the problem, but is a quick workaround. In any case, you may have other reasons to want to exclude a directory, so it’s still good to know.