google / zoekt

Fast trigram based code search
1.67k stars 113 forks source link

Problem when using ctags: "write |1: file already closed" #131

Closed grimbough closed 3 years ago

grimbough commented 3 years ago

Thanks for this awesome tool. It's really great! However I'm having some issues getting ctags working.

I've been trying to use Docker to get a containerised version of zoekt-index working with ctags. Since Alpine doesn't have a pre-built ctags that has JSON support, I've based the ctags installation part on the Docker file from Sourcegraph project (https://github.com/sourcegraph/zoekt/blob/master/Dockerfile). The container builds and it seems to have a working version of universal-ctags.

However, when I run zoekt-index the actual indexing works, but I always encounter the following error from ctags:

$ zoekt-index -index /var/zoekt/ /var/git/Biobase
/var/git/Biobase
2021/03/30 07:13:06 ignoring /usr/local/bin/universal-ctags error: write |1: file already closed
2021/03/30 07:13:06 finished /var/zoekt/Biobase_v15.00000.zoekt: 2384409 index bytes (overhead 3.1)

I was wondering if you'd seen this before, or had any pointers. I'm new to GO and it's likely I'm missing something.

hanwen commented 3 years ago

the error messages reads as if it doesn't support the JSON communication mode in universal-ctags (there are a ton of compilation modes).

I don't know that sourcegraph uses ctags at all. I thought they have their own parsing machinery.

easiest is to compile ctags from source as detailed here: https://github.com/google/zoekt/blob/master/doc/ctags.md

or download from https://storage.googleapis.com/zoekt-binaries/ctags-2020-08-26T1308-c9ebd839.tar.gz

grimbough commented 3 years ago

Thanks for the tips. It must be something in the way I am building universal-ctags. I haven't figured a fix to the compilation, but the pre-built binary you supplied works perfectly.

For anyone stumbling across this at a later date, here's an example Dockerfile that makes used of the supplied ctags binary.