irony-mode icon indicating copy to clipboard operation
irony-mode copied to clipboard

Company: An error occurred in auto-begin

Open junkudo opened this issue 7 years ago • 15 comments

Hey, Having some trouble getting irony mode working on this machine. I'm getting this error when I invoke company-irony directly in my file :

Company: An error occurred in auto-begin
Buffer xxx.cpp has no process
user-error: Cannot complete at point

Here's my init.el:

;; company-mode
(require 'company)
(add-hook 'after-init-hook 'global-company-mode)

;; irony
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'objc-mode-hook 'irony-mode)

;; If you want to enable tab-completion with no delay use the following:
(defun my-irony-mode-hook ()
  (define-key irony-mode-map [remap completion-at-point]
    'irony-completion-at-point-async)
  (define-key irony-mode-map [remap complete-symbol]
    'irony-completion-at-point-async))

(add-hook 'irony-mode-hook 'my-irony-mode-hook)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)

;; company-irony
(add-hook 'irony-mode-hook 'company-irony-setup-begin-commands)
(setq company-backends (delete 'company-semantic company-backends))
(eval-after-load 'company
  '(progn
     (add-to-list 'company-backends 'company-irony)))

;; Tab completion
(setq company-idle-delay 0)
;; ==========================================
;; (optional) bind TAB for indent-or-complete
;; ==========================================
(defun irony--check-expansion ()
  (save-excursion (if (looking-at "\\_>") t (backward-char 1)
                      (if (looking-at "\\.") t (backward-char 1)
                          (if (looking-at "->") t nil)))))
(defun irony--indent-or-complete
  () "Indent or Complete" (interactive) (cond ((and (not (use-region-p)) (irony--check-expansion)) (message "complete")
                                               (company-complete-common)) (t (message "indent")
                                                                             (call-interactively 'c-indent-line-or-region))))
(defun irony-mode-keys () "Modify keymaps used by `irony-mode'."
  (local-set-key (kbd "TAB") 'irony--indent-or-complete) (local-set-key [tab] 'irony--indent-or-complete))
(add-hook 'c-mode-common-hook 'irony-mode-keys)

I can invoke my server manually and it seems to be working

$~/.emacs.d/irony/bin/irony-server --version
irony-server version 1.1.0
clang version 4.0.0 (tags/RELEASE_400/final)

Let me know if there's anything obviously wrong!

junkudo avatar Oct 02 '17 19:10 junkudo

What happens if you call M-x completion-at-point RET?

struct Foo
{
  int foobar;
  int foobaz;
};

void f(const Foo&foo)
{
  foo.| // cursor here
}

Sarcasm avatar Oct 02 '17 21:10 Sarcasm

 process-live-p: Buffer xxx.cpp has no process

junkudo avatar Oct 02 '17 21:10 junkudo

Same issue with M-x irony-version RET?

Sarcasm avatar Oct 02 '17 21:10 Sarcasm

Nope. That works: irony version: 1.1.0

junkudo avatar Oct 02 '17 22:10 junkudo

Hum, I have no clue for now, maybe it is a recent change, and you could try the version from MELPA stable. Or you can you try to get a stacktrace with M-x toggle-debug-on-error RET.

Sarcasm avatar Oct 02 '17 22:10 Sarcasm

What version did you have in mind? The MELPA stable versions are 1.1.0.

junkudo avatar Oct 02 '17 22:10 junkudo

I was thinking about testing this 1.1.0 version.

Sarcasm avatar Oct 02 '17 22:10 Sarcasm

Here's the stack trace if it's of any use to you. M-x company-irony RET :

1  Debugger entered--Lisp error: (error "Buffer jun.cpp has no process")
2    process-status(nil)
3    process-live-p(nil)
4    irony--get-server-process-create()
5    irony--unsaved-buffers-tasks()
6    irony--complete-task(nil 78)
7    irony--candidates-task(nil 78 "" case-insensitive)
8    irony-completion-candidates-async(#[257 "\300\301^B!!\207" [#[257 "\300^A\240\207" [(trash)] 3 "\n\n(fn RESULT)"] company-irony--make-candidates] 4 "\n\n(fn CANDIDATES)"] "" case-insensitive)
9    #[257 "\301\302\303\304\305\306^F^F!\307\"\310\311%\300\312 #\207" ["" irony-completion-candidates-async make-byte-code 257 "\300\301^B!!\207" vconcat vector [company-irony--make-candidates] 4 "\n\n(fn CANDIDATES)" company-irony--g$
10   company--force-sync(company-call-backend-raw (candidates "") company-irony)
11   company-call-backend(candidates "")
12   company--fetch-candidates("")
13   company-calculate-candidates("")
14   #[0 "\n\203   ^@\nC\202\n^@^K\211\205\207^@\211@\300^A9\204^\^@\306^B!\203(^@\307^B!\205,^@^A\310!\202,^@\311^B\310\"\240\210\300@\203\200^@\312\300@!\203z^@\313\300@!^T\211^R\301\314\f!\240\210\301@:\204c^@^M\203U^@\315\316!\210\3$
15   funcall(#[0 "\n\203   ^@\nC\202\n^@^K\211\205\207^@\211@\300^A9\204^\^@\306^B!\203(^@\307^B!\205,^@^A\310!\202,^@\311^B\310\"\240\210\300@\203\200^@\312\300@!\203z^@\313\300@!^T\211^R\301\314\f!\240\210\301@:\204c^@^M\203U^@\315\31$
16   company--begin-new()
17   company--perform()
18   #[0 "\301 \210^H\207" [company-candidates company--perform] 1 "\n\n(fn)"]()
19   company-auto-begin()
20   company-manual-begin()
21   company-begin-backend(company-irony)
22   company-irony(interactive)
23   call-interactively(company-irony record nil)
24   command-execute(company-irony record)
25   execute-extended-command(nil "company-irony")
26   call-interactively(execute-extended-command nil nil)

M-x completion-at-point RET :

1  Debugger entered--Lisp error: (error "Buffer jun.cpp has no process")
2    process-status(nil)
3    process-live-p(nil)
4    irony--get-server-process-create()
5    irony--unsaved-buffers-tasks()
6    irony--complete-task(nil 78)
7    irony--candidates-task(nil 78 "" exact)
8    irony-completion-at-point()
9    completion--capf-wrapper(irony-completion-at-point all)
10   run-hook-wrapped(completion--capf-wrapper irony-completion-at-point all)
11   completion-at-point()
12   call-interactively(completion-at-point record nil)
13   command-execute(completion-at-point record)
14   execute-extended-command(nil "completion-at-point")
15   call-interactively(execute-extended-command nil nil)

Do you recommend trying older versions to try to get it to work?

junkudo avatar Oct 02 '17 22:10 junkudo

Do you recommend trying older versions to try to get it to work?

Yes, 1.1.0 from MELPA stable at least.

Did you restart your Emacs since you have been noticing this issue?

What does M-: irony--server-process RET prints? Does it still bug after you do M-: (setq irony--server-process nil) RET?

Sarcasm avatar Oct 02 '17 23:10 Sarcasm

Yes, 1.1.0 from MELPA stable at least.

Aren't I already using irony version 1.1.0 or am I misunderstanding the suggestion?

Did you restart your Emacs since you have been noticing this issue?

Yes I have.

What does M-: irony--server-process RET prints?

M-: irony--server-process RET returns nil.

Does it still bug after you do M-: (setq irony--server-process nil) RET?

Yes

junkudo avatar Oct 02 '17 23:10 junkudo

Aren't I already using irony version 1.1.0 or am I misunderstanding the suggestion?

The non-stable versions of MELPA has 1.1.0 + changes from the master branch, soon it will be called 1.2.0, but there is the 1.0.0 from MELPA stable, which is really the tag 1.1.0. The 1.1.0, now 1.2.0, is just the current state of the git repository but it's a moving version different from the one on MELPA stable.

Sarcasm avatar Oct 02 '17 23:10 Sarcasm

How do you know which 1.1.0 version I have?

junkudo avatar Oct 02 '17 23:10 junkudo

There are multiples methods, but you can take a look at the irony-completion-candidates-async function to see you have this change:

  • https://github.com/Sarcasm/irony-mode/commit/6579e7be6b571c7bd96f082669469aafd97598c2

This is the first change after the 1.1.0.

Sarcasm avatar Oct 02 '17 23:10 Sarcasm

I re-installed irony and company-irony from MELPA stable and am still running into the same issue. I also confirmed that I do not have that change you indicated.

junkudo avatar Oct 02 '17 23:10 junkudo

I am facing exactly the same issue as @junkudo on one of my machines (with Ubuntu 14.04). Did you find a solution?

EDIT: I solved the problem by upgrading emacs from version 24.3.1 to 25.3.2.

rempfler avatar Nov 02 '17 09:11 rempfler