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

deoplete-clang get errors

Open andrea993 opened this issue 9 years ago • 23 comments

Deoplete-clang doesn't work I get this error when it should complete the cpp syntax:

[deoplete] Could not get completions from: clang.  Use :messages for error details.   

:messages says:

[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
te_clang.py", line 151, in gather_candidates                                                         
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/clang/clang/ci
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/clang/clang/ci
"pippo.cpp" 8L, 65C                                                                                  
[deoplete] Traceback (most recent call last):                                                        
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", l
ine 98, in gather_results                                                                            
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)                                     
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
te_clang.py", line 151, in gather_candidates                                                         
[deoplete]     params)                                                                               
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
te_clang.py", line 314, in get_completion                                                            
[deoplete]     tu = self.get_translation_unit(fname, args, buf)                                      
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
te_clang.py", line 301, in get_translation_unit                                                      
[deoplete]     tu = self.index.parse(fname, args, buf, flags)                                        
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/clang/clang/ci
ndex.py", line 2322, in parse                                                                        
[deoplete]     self)                                                                                 
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/clang/clang/ci
ndex.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/andrearch/.vim/bundle/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", l
ine 98, in gather_results                                                                            
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)                                     
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
te_clang.py", line 151, in gather_candidates                                                         
[deoplete]     params)                                                                               
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
te_clang.py", line 314, in get_completion                                                            
[deoplete]     tu = self.get_translation_unit(fname, args, buf)                                      
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
te_clang.py", line 301, in get_translation_unit                                                      
[deoplete]     tu = self.index.parse(fname, args, buf, flags)                                        
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/clang/clang/ci
ndex.py", line 2322, in parse                                                                        
[deoplete]     self)                                                                                 
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/clang/clang/ci
ndex.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. 

this is my init.vim https://arin.ga/pN1SjM

andrea993 avatar Oct 13 '16 21:10 andrea993

@andrea993 Thanks issue :)

Hmm.. I have not yet debug, will check it. Sorry, if you have time, could you post a sample C source at occurring this problem?

zchee avatar Oct 14 '16 01:10 zchee

I have this issue with all .cpp files

#include <iostream>

using namespace std;

int main()
{
    std::
}

If. for example. I go at the end of std:: and I press a to write I get the error

andrea993 avatar Oct 14 '16 07:10 andrea993

@andrea993 I think your problem same as https://github.com/zchee/deoplete-clang/pull/54 That's not yet merged, but Could you try it?

zchee avatar Oct 14 '16 08:10 zchee

@andrea993

  • Please upload the compilation database file.
  • I cannot get your init.vim. Please upload it to another place.

Shougo avatar Nov 30 '16 23:11 Shougo

Rather than creating another issue, this issue seems to be similar if not the same.

I do not know what the compilation database file is, @Shougo, where would this file be located?

Minimal init.vim

" init.vim

" dein plugin manager
function! InstallPluginManager()
    echom 'Installing dein...'
    silent! call mkdir($XDG_CONFIG_HOME . '/nvim/dein', 'p')
    silent! execute '!curl --fail --location --output /tmp/dein.sh '
             \ . 'https://raw.githubusercontent.com/'
             \ . 'Shougo/dein.vim/master/bin/installer.sh'
    silent! execute '!sh /tmp/dein.sh ' . $XDG_CONFIG_HOME . '/nvim/dein'
endfunction

if !filereadable($XDG_CONFIG_HOME . '/nvim/dein/'
            \ . 'repos/github.com/Shougo/dein.vim/autoload/dein.vim')
    call InstallPluginManager()
endif

set runtimepath+=$XDG_CONFIG_HOME/nvim/dein/repos/github.com/Shougo/dein.vim
call dein#begin($XDG_CONFIG_HOME . '/nvim/dein')
call dein#add('Shougo/dein.vim')
call dein#add('Shougo/deoplete.nvim')
call dein#add('zchee/deoplete-clang')
call dein#end()

if dein#check_install()
    call dein#install()
endif

filetype plugin indent on
syntax enable
call deoplete#enable()
autocmd CompleteDone * pclose

The test file I used was:

// test.cc

#include <vector>

std

As typing the d in std the following errors were printed to :messages

[deoplete] Traceback (most recent call last):
[deoplete]   File "/home/parnmatt/.dotfiles/nvim/.config/nvim/dein/.cache/init.vim/.dein/rplugin/python3/deoplete/deoplete.py", line 100, in gather_results
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)
[deoplete]   File "/home/parnmatt/.config/nvim/dein/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 151, in gather_candidates
[deoplete]     params)
[deoplete]   File "/home/parnmatt/.config/nvim/dein/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 314, in get_completion
[deoplete]     tu = self.get_translation_unit(fname, args, buf)
[deoplete]   File "/home/parnmatt/.config/nvim/dein/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 301, in get_translation_unit
[deoplete]     tu = self.index.parse(fname, args, buf, flags)
[deoplete]   File "/home/parnmatt/.config/nvim/dein/.cache/init.vim/.dein/rplugin/python3/deoplete/clang/clang/cindex.py", line 2322, in parse
[deoplete]     self)
[deoplete]   File "/home/parnmatt/.config/nvim/dein/.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.

parnmatt avatar Dec 04 '16 15:12 parnmatt

I do not know what the compilation database file is, @Shougo, where would this file be located?

Hm. It is not specified. We should improve the error message. But where is your libclang installed? I think you need to set it like this.

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

Shougo avatar Dec 04 '16 15:12 Shougo

Indeed, libclang is located, and symlinked to /usr/lib/libclang.so -> libclang.so.3.9.

This is a standard place for the library to be located, and certainly should be in the library path. Why wouldn't this be found by neovim / deoplete-clang?

I will try the minimal configuration with the path hardcoded as suggested and get back to you.

parnmatt avatar Dec 04 '16 20:12 parnmatt

This is a standard place for the library to be located, and certainly should be in the library path. Why wouldn't this be found by neovim / deoplete-clang?

Unfortunately, it is not standard. This is for Ubuntu 16.04 configuration.

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

Shougo avatar Dec 04 '16 23:12 Shougo

Yep correcting this has solved my issue. I correctly pointed libclang_path and clang_header to the correct paths.

However the moment I start typing #include it freezes (I assume looking for headers to complete; and uses ) for 5-10; and does so whenever I edit on that line.

parnmatt avatar Dec 07 '16 20:12 parnmatt

Yes, deoplete-clang has many performance problems. But it will be fixed by @zchee .

Shougo avatar Dec 07 '16 22:12 Shougo

I'm also having a similar problem, can we just get deoplete-clang to ignore lines that start with '#'?

(or have an option for that)

Cypher1 avatar Dec 09 '16 07:12 Cypher1

I have the same issue (I think?) but setting libclang_path and clang_header did not solve it. The really weird thing is that after the error, completion works just fine.

Is there something I can try to provide you with more debug information?

kierun avatar Dec 19 '16 11:12 kierun

I have the same problem. Any update on the issue?

sshtmc avatar Mar 06 '17 15:03 sshtmc

You should use deoplete-clang2 instead.

https://github.com/tweekmonster/deoplete-clang2

Shougo avatar Mar 08 '17 23:03 Shougo

Why is there a second deoplete rather than a second version?

Cypher1 avatar Mar 08 '17 23:03 Cypher1

Because, @zchee implements the new version of deoplete-clang. He is very busy. No time to fix the bugs in deoplete-clang currently.

Shougo avatar Mar 08 '17 23:03 Shougo

Hmm, fair enough, couldn't we just have branches to facilitate visibility and merging?

Deoplete is an awesome plugin, I'd hate to see two parts diverge and end up with incompatible features.

Cypher1 avatar Mar 09 '17 02:03 Cypher1

@Cypher1 I think there's a misunderstanding (from the eyes of a complete outsider). Deoplete is a separate project from deoplete-clang. Deoplete stays as is. However, deoplete-clang had too high code complexity (it seems) and now there's going to be deoplete-clang2.

But regardless of the above, I would also like to see deoplete-clang2 replace deoplete-clang (become version 2). IMHO there's no point in having deoplete-clang if it's full of bugs and nobody is maintaining it.

sshtmc avatar Mar 09 '17 07:03 sshtmc

This is going to add to the confusions of users unless someone actually write this on the main README…

kierun avatar Mar 09 '17 07:03 kierun

I just tried deoplete-clang2 (https://github.com/tweekmonster/deoplete-clang2) and it worked great, without any issues.

sshtmc avatar Mar 09 '17 09:03 sshtmc

@Cypher1 I think there's a misunderstanding (from the eyes of a complete outsider). Deoplete is a separate project from deoplete-clang. Deoplete stays as is. However, deoplete-clang had too high code complexity (it seems) and now there's going to be deoplete-clang2.

Yes.

But regardless of the above, I would also like to see deoplete-clang2 replace deoplete-clang (become version 2). IMHO there's no point in having deoplete-clang if it's full of bugs and nobody is maintaining it.

I like deoplete-clang than deoplete-clang2. deoplete-clang will be rewritten.

Shougo avatar Mar 12 '17 01:03 Shougo

Hi! I have the same problem. My PC is on Debian testing. My libclang is at /usr/lib/llvm-3.8/lib/libclang.so. I tried deoplete-clang2 but I get errors too, even if I write let g:deoplete#sources#clang#executable='/usr/bin/clang', let g:deoplete#sources#clang#executable='/usr/bin/clang2' or let g:deoplete#sources#clang#executable='/usr/bin/clang-3.8'.

Have you an idea?

Thanks.

Deirdan avatar Apr 07 '17 23:04 Deirdan

I tried deoplete-clang2 but I get errors too, even if I write let

You should create new issue in deoplete-clang2.

Shougo avatar Apr 09 '17 14:04 Shougo