deoplete-clang icon indicating copy to clipboard operation
deoplete-clang copied to clipboard

TranslationUnitLoadError

Open covercash2 opened this issue 7 years ago • 6 comments

Problems summary

just trying to get autocomplete with neovim.

from neovim :messages : http://pastebin.com/d48cuBTR

this is very similar to #59, but that seems to be solved with setting the right clang paths, which I think I have set correctly in my init.vim (this is minimal, but confirmed): http://pastebin.com/MPHVLRD1

I've installed llvm/clang with homebrew and had the same problem, but my current llvm I compiled into my home tree.

I get the same behavior as #59 where I type std and deoplete-clang goes nuts. also happens with sf (SFML).

Expected

autocomplete

Environment Information

  • OS: macOS 10.11.6
  • Neovim version: 0.1.7

reproduce

  1. install neovim
  2. run my init.vim using plug, deoplete, and deoplete-clang, also setting libclang and clang headers path
  3. try to write c/c++
  4. chain smoke and cry

logfile

I generated this logfile: http://pastebin.com/dakv1Seu

Screen shot

nvim fucking up.jpg

conclusion

let me know if you need anything else or about any work-arounds

covercash2 avatar Dec 14 '16 00:12 covercash2

I have the same problem.

ghost avatar Jan 02 '17 11:01 ghost

~@covercash2 @stjepang You should read README.md carefully. g:deoplete#sources#clang#libclang_path and g:deoplete#sources#clang#clang_header are needed to work this plugin.~

sry 😢

example (tested with Arch Linux)

let g:deoplete#sources#clang#libclang_path='/usr/lib/libclang.so'
let g:deoplete#sources#clang#clang_header='/usr/lib/clang'

mikoim avatar Jun 02 '17 06:06 mikoim

here's the same init file i originally posted. also, this issue was only on macOS.

i tried to be thorough in my original report.

covercash2 avatar Jun 02 '17 06:06 covercash2

I think it depends clang version. Using deoplete-clang2 is recommended.

Shougo avatar Jun 02 '17 07:06 Shougo

I get same errors:


[deoplete] Traceback (most recent call last):
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/repos/github.com/Shougo/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 136, in gather_results
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 151, in gather_candidates
[deoplete]     params)
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 318, in get_completion
[deoplete]     tu = self.get_translation_unit(fname, args, buf)
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 305, in get_translation_unit
[deoplete]     tu = self.index.parse(fname, args, buf, flags)
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/clang/clang/cindex.py", line 2322, in parse
[deoplete]     self)
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/clang/clang/cindex.py", line 2440, in from_source
[deoplete]     raise TranslationUnitLoadError("Error parsing translation unit.")
[deoplete] clang.cindex.TranslationUnitLoadError: Error parsing translation unit.
[deoplete] Could not get completions from: clang.  Use :messages for error details.
[deoplete] Traceback (most recent call last):
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/repos/github.com/Shougo/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 136, in gather_results
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 151, in gather_candidates
[deoplete]     params)
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 318, in get_completion
[deoplete]     tu = self.get_translation_unit(fname, args, buf)
[deoplete] Too many errors from "clang". This source is disabled until Neovim is restarted.
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 305, in get_translation_unit
[deoplete] Too many errors from "clang". This source is disabled until Neovim is restarted.
[deoplete]     tu = self.index.parse(fname, args, buf, flags)
[deoplete] Traceback (most recent call last):
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/clang/clang/cindex.py", line 2322, in parse
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/repos/github.com/Shougo/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 136, in gather_results
[deoplete]     self)
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/clang/clang/cindex.py", line 2440, in from_source
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 151, in gather_candidates
[deoplete]     raise TranslationUnitLoadError("Error parsing translation unit.")
[deoplete]     params)
[deoplete] clang.cindex.TranslationUnitLoadError: Error parsing translation unit.
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 318, in get_completion
[deoplete] Could not get completions from: clang.  Use :messages for error details.
[deoplete]     tu = self.get_translation_unit(fname, args, buf)
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 305, in get_translation_unit
[deoplete]     tu = self.index.parse(fname, args, buf, flags)
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/clang/clang/cindex.py", line 2322, in parse
[deoplete]     self)
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/.cache/init.vim/.dein/rplugin/python3/deoplete/clang/clang/cindex.py", line 2440, in from_source
[deoplete]     raise TranslationUnitLoadError("Error parsing translation unit.")
[deoplete] clang.cindex.TranslationUnitLoadError: Error parsing translation unit.
[deoplete] 
[deoplete] During handling of the above exception, another exception occurred:
[deoplete] 
[deoplete] Traceback (most recent call last):
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/repos/github.com/Shougo/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 59, in completion_begin
[deoplete]     self.gather_results(context), context['input'])
[deoplete]   File "/home/wsdjeg/.cache/vimfiles/repos/github.com/Shougo/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 162, in gather_results
[deoplete]     self._sources.pop(source.name)
[deoplete] KeyError: 'clang'
[deoplete] Error while gathering completions.  Use :messages for error details.

wsdjeg avatar Dec 03 '17 16:12 wsdjeg

Sometimes it was just a matter of removing the translation unit file again. (The .tu file) And it all works again.

hwalinga avatar Oct 19 '23 16:10 hwalinga