emacs-counsel-gtags icon indicating copy to clipboard operation
emacs-counsel-gtags copied to clipboard

counsel-gtags-find-symbol shows error code 1

Open braun-steven opened this issue 3 years ago • 6 comments

Running in a sandboxed Emacs using only

(eval-when-compile
  (add-to-list 'load-path "~/use-package")
  (require 'use-package))

(use-package counsel
  :ensure t)
(use-package counsel-gtags
  :ensure t)

and generating the database with global --gtagslabel=pygments . (and ctags, new-ctags) as well, I end up with error code 1 when running counsel-gtags-find-symbol after typing three chars.

Is there any way to look into what error code 1 means?

System Information:

  • Emacs 27.1
  • GNU Global 6.6.5
  • Universal Ctags 5.9.0
  • Exuberant Ctags 5.8

braun-steven avatar Nov 30 '20 15:11 braun-steven

hey

before diving into this:

  • can you provide a mvce? (check the unit tests)
  • can you try global-tags (I think the corresponding command is xref-find-definitions)

Error code 1 is Ivy telling you that the (last) async command to fetch candidates returned non-zero (something went wrong). Unfortunately, that's not very informative, so we need to dig deeper into this together.

FelipeLema avatar Nov 30 '20 19:11 FelipeLema

Thanks for the fast response!

can you provide a mvce? (check the unit tests)

I'm not familiar with elisp unit tests at all, sorry. Can you give me a head start what to look for, so I can build a mcve?

can you try global-tags (I think the corresponding command is xref-find-definitions)

Ok, I just did that. Here is an example:

$ cat hello.rb
class Hello
  def hello
    puts message
  end

  def message; 'hello, world'; end
end

$ gtags

$ ls
.rw-r--r-- 16k st  1 Dec 10:27 GPATH
.rw-r--r-- 16k st  1 Dec 10:27 GRTAGS
.rw-r--r-- 16k st  1 Dec 10:27 GTAGS
.rw-r--r--  87 st  1 Dec 10:16 hello.rb

$ global -sx message hello.rb
message             3 hello.rb             puts message
message             6 hello.rb           def message; 'hello, world'; end

So gtags seems to work as expected.

When I open the hello.rb file in the emacs configuration as described above (including global-tags.el now) and run xref-find-definitions, the echo message shows

Visit tags table (default TAGS): /tmp/test/

Using one of /tmp/test/GPATH, /tmp/test/GRTAGS or /tmp/test/GTAGS leads to the message

File /tmp/test/GTAGS is not a valid tags table

(same for GPATH and GRTAGS).

braun-steven avatar Dec 01 '20 09:12 braun-steven

I think xref tried using "Emacs Tags" instead of "GNU Global Tags" in your latest example.

You probably missed (add-to-list 'xref-backend-functions 'global-tags-xref-backend) ? It would be worth removing any other xref backend just for doing this test: (setq xref-backend-functions '(global-tags-xref-backend))

(come to think of it, it may be worth to update global-tags to do this automagically)

FelipeLema avatar Dec 01 '20 15:12 FelipeLema

You're right, I was missing this.

Now, xref-find-apropos with mes as argument shows the following buffer:

hello.rb
3:      puts message
6:    def message; 'hello, world'; end

So that seems to work correctly.

braun-steven avatar Dec 01 '20 15:12 braun-steven

let me try to debug it on my side (involves defining advice around counsel--async-process).

It's going to take a few days. I personally use global-tags + ivy-xref in case you want to switch to that in the meantime.

FelipeLema avatar Dec 01 '20 19:12 FelipeLema

Sorry, but I have no idea about Ruby, I tried to reproduce your issue, but

$ cat hello.rb
class Hello
  def hello
    puts message
  end

  def message; 'hello, world'; end
end

$ gtags

$ ls
.rw-r--r-- 16k st  1 Dec 10:27 GPATH
.rw-r--r-- 16k st  1 Dec 10:27 GRTAGS
.rw-r--r-- 16k st  1 Dec 10:27 GTAGS
.rw-r--r--  87 st  1 Dec 10:16 hello.rb

Up to here everything works fine.

$ global -sx message hello.rb

But here I got nothing as output. Does global needs anything special to work with ruby? I tried exactly the same example with a C and C++ code and it worked perfectly. From the terminal and with counsel-gtags...

Ergus avatar Dec 03 '20 14:12 Ergus