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

ggtags not prompting for project root #109

Closed
blaenk opened this issue Jul 26, 2015 · 15 comments
Closed

ggtags not prompting for project root #109

blaenk opened this issue Jul 26, 2015 · 15 comments

Comments

@blaenk
Copy link

blaenk commented Jul 26, 2015

I read that ggtags either looks for the GTAGS file or prompts for the project root, but when I start emacs for a file (say init.el) it just dumps me in Backtrace with the following error:

Debugger entered--Lisp error: (error "`global' non-zero exit: global: GTAGS not found.")
  signal(error ("`global' non-zero exit: global: GTAGS not found."))
  error("`%s' non-zero exit: %s" "global" "global: GTAGS not found.")
  ggtags-process-string("global" "-pr")
  #[0 "\301\302�!\303\304\305\"P!\207" [default-directory file-name-as-directory file-remote-p ggtags-process-string "global" "-pr"] 5 "\n\n(fn)"]()
  funcall(#[0 "\301\302�!\303\304\305\"P!\207" [default-directory file-name-as-directory file-remote-p ggtags-process-string "global" "-pr"] 5 "\n\n(fn)"])
  ggtags-find-project()
  ggtags-highlight-tag-at-point()
  apply(ggtags-highlight-tag-at-point nil)
  byte-code("r\301�\302H�\303H\"\210)\301\207" [timer apply 5 6] 4)
  timer-event-handler([t 0 0 250000 t ggtags-highlight-tag-at-point nil idle 0])

I do have debug-on-error enabled, could it be that?

@blaenk
Copy link
Author

blaenk commented Jul 26, 2015

I added it to my debug-ignored-errors so now I don't get a backtrace buffer but I also still don't get a prompt, so maybe that wasn't it?

(push "non-zero exit: global: GTAGS not found" debug-ignored-errors)

@leoliu
Copy link
Owner

leoliu commented Jul 27, 2015

Looks like you may have ggtags-mode enabled incorrectly. First, pick the major modes that you would like to use ggtags-mode and enable it accordingly. For example, put (add-hook 'c-mode-hook 'ggtags-mode) in your init file will enable it for .c files. Open .c file and try M-.. it will prompt for the project root if GTAGS not found. See the README for details that I might miss.

@blaenk
Copy link
Author

blaenk commented Jul 27, 2015

Hmm, this is what I have currently. Do you see anything wrong?

(use-package ggtags
  :ensure t

  :init
  (setenv "GTAGSCONF" "/home/blaenk/.globalrc")
  (setenv "GTAGSLABEL" "ctags")
  (push "GTAGS not found" debug-ignored-errors)

  :config
  (add-hook 'prog-mode-hook 'ggtags-mode))

The only other thing relating to ggtags I have is to make its keymap override evil's:

  (with-eval-after-load 'ggtags
    (evil-make-overriding-map ggtags-mode-map)

    ;; force update evil keymaps after ggtags-mode loaded
    (add-hook 'ggtags-mode-hook #'evil-normalize-keymaps))

Is there some caching ggtags does somewhere? Could it be that my 'project root' changed somehow, so it's still trying to find the stuff in the old root?

@blaenk
Copy link
Author

blaenk commented Jul 28, 2015

I'm no longer getting this error, no idea why. Will close.

@blaenk blaenk closed this as completed Jul 28, 2015
@blaenk
Copy link
Author

blaenk commented Jul 28, 2015

No yeah, this is happening, and I don't know why, especially because I can create the tags manually if I want with ggtags-create-tags, it's just that when I open a file for which ggtags-mode gets enabled, it gives me that error.

@blaenk blaenk reopened this Jul 28, 2015
@blaenk
Copy link
Author

blaenk commented Jul 28, 2015

I think it's something to do with the environment variables, which I have to set to enable Rust support for global via ctags. I'll close this for now to avoid cluttering things up. I'll keep this updated if I find something else.

@blaenk blaenk closed this as completed Jul 28, 2015
@seudut
Copy link

seudut commented Sep 3, 2016

I also met this error after I enabled debug-ignored-errors, then open a .c file, any idea for this?

@leoliu
Copy link
Owner

leoliu commented Sep 4, 2016

Do you mean debug-on-error?

@seudut
Copy link

seudut commented Sep 4, 2016

Yes, I meansetq debug-on-error t. sorry for the typo

@leoliu
Copy link
Owner

leoliu commented Sep 4, 2016

check the buffer ggtags-global for anything suspicious. turn on debug-on-error for debugging purposes. some functions may have different semantics in ggtags or elsewhere.

@seudut
Copy link

seudut commented Sep 4, 2016

Thanks @leoliu , there is no buffer named ggtags-global in my case. when this buffer will be generated?

Here is all my settings for ggtags,

(use-package ggtags
  :ensure t
  :config
  (define-key ggtags-mode-map (kbd "M-g d") 'ggtags-find-definition)
  (define-key ggtags-mode-map (kbd "M-g r") 'ggtags-find-reference)
  (define-key ggtags-mode-map (kbd "M-g r") 'ggtags-find-reference)
  (define-key ggtags-mode-map (kbd "C-c g s") 'ggtags-find-other-symbol)
  (define-key ggtags-mode-map (kbd "C-c g h") 'ggtags-view-tag-history)
  (define-key ggtags-mode-map (kbd "C-c g r") 'ggtags-find-reference)
  (define-key ggtags-mode-map (kbd "C-c g f") 'ggtags-find-file)
  (define-key ggtags-mode-map (kbd "C-c g c") 'ggtags-create-tags)
  (define-key ggtags-mode-map (kbd "C-c g u") 'ggtags-update-tags))

(add-hook 'c-mode-common-hook
          (lambda ()
            (when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
              (ggtags-mode 1))))

And when I open an .c file, it pops up this error trace

Debugger entered--Lisp error: (error "‘global’ non-zero exit: global: GTAGS not found.")
  signal(error ("‘global’ non-zero exit: global: GTAGS not found."))
  error("`%s' non-zero exit: %s" "global" "global: GTAGS not found.")
  ggtags-process-string("global" "-pr")
  ggtags-find-project()
  ggtags-highlight-tag-at-point()
  apply(ggtags-highlight-tag-at-point nil)
  timer-event-handler([t 0 0 250000 t ggtags-highlight-tag-at-point nil idle 0])

I am not sure when this function ggtags-highlight-tag-at-point is called, any idea for this?

@seudut
Copy link

seudut commented Sep 4, 2016

By the way, after I generated the GTAGS files by running gtags commands on the project directory in terminal. then the error is gone when I open the .c file.

So, looks like this error only happens when my project has no GTAGS files. Is this the expected behavior?

@leoliu
Copy link
Owner

leoliu commented Sep 5, 2016

hi @seudut,

When debug-on-error is enabled, many things in emacs will behave differently. So some functions that don't normally throw errors do so with debug-on-error. I think the solution is not to turn on debug-on-error unless you are debugging.

The error you are seeing is due to ggtags-find-project not silencing some errors with debug-on-error.

My normal routine to use ggtags on a new project is like this:

  1. open a source file in a project
  2. M-x ggtags
  3. M-.

At this point if there is no GTAGS file in the project ggtags will ask for the project root and index the project recursively. Doing it this way has the minor benefit of choosing the ctags backend when applicable.

HTH,
Leo

@seudut
Copy link

seudut commented Sep 7, 2016

Thanks very much @leoliu

@leoliu
Copy link
Owner

leoliu commented Sep 7, 2016

Thanks. BTW, there is command toggle-debug-on-error so that one can quickly flip debug-on-error.

leoliu added a commit that referenced this issue Oct 22, 2016
leoliu added a commit that referenced this issue Oct 22, 2016
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