Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

counsel-gtags-find-symbol shows error code 1 #22

Open
braun-steven opened this issue Nov 30, 2020 · 6 comments
Open

counsel-gtags-find-symbol shows error code 1 #22

braun-steven opened this issue Nov 30, 2020 · 6 comments

Comments

@braun-steven
Copy link

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
@FelipeLema
Copy link
Owner

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.

@braun-steven
Copy link
Author

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).

@FelipeLema
Copy link
Owner

FelipeLema commented Dec 1, 2020

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)

@braun-steven
Copy link
Author

braun-steven commented Dec 1, 2020

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.

@FelipeLema
Copy link
Owner

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.

@Ergus
Copy link
Collaborator

Ergus commented Dec 3, 2020

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants