ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.44k stars 2.81k forks source link

YCM in python runtime error Can‘t jump jump to definition #3794

Closed tricomm closed 3 years ago

tricomm commented 3 years ago

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your issue:

Thank you for adhering to this process! It ensures your issue is resolved quickly and that neither your nor our time is needlessly wasted.

Issue Details

Provide a clear description of the problem, including the following key questions:

  1. vim -Nu /path/to/YCM/ycm_vimrc_minimal
  2. :edit test.py
  3. Enter insert mode and type .....

Include description of a minimal test case, including any actual code required to reproduce the issue.

If you made changes to vimrc_ycm_minimal, pase them here:

<contents of ycm_vimrc_minimal>

Include description of the observed behaviour, including actual output, screenshots, etc.

Diagnostic data

Output of vim --version

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep  9 2020 23:27:04)
Unknown option argument: "--vision"
More info with: "vim -h"
siiyrang@siiydeMacBook ~ % vim -vision
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep  9 2020 23:27:04)
Garbage after option argument: "-vision"
More info with: "vim -h"
siiyrang@siiydeMacBook ~ % vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep  9 2020 23:27:04)
macOS version
Included patches: 1-1650
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               -farsi             +mouse_sgr         +tag_binary
+arabic            +file_in_path      -mouse_sysmouse    -tag_old_static
+autocmd           +find_in_path      +mouse_urxvt       -tag_any_white
+autochdir         +float             +mouse_xterm       -tcl
-autoservername    +folding           +multi_byte        +termguicolors
-balloon_eval      -footer            +multi_lang        +terminal
+balloon_eval_term +fork()            -mzscheme          +terminfo
-browse            +gettext           +netbeans_intg     +termresponse
++builtin_terms    -hangul_input      +num64             +textobjects
+byte_offset       +iconv             +packages          +textprop
+channel           +insert_expand     +path_extra        +timers
+cindent           +ipv6              +perl              +title
-clientserver      +job               +persistent_undo   -toolbar
+clipboard         +jumplist          +popupwin          +user_commands
+cmdline_compl     +keymap            +postscript        +vartabs
+cmdline_hist      +lambda            +printer           +vertsplit
+cmdline_info      +langmap           +profile           +virtualedit
+comments          +libcall           -python            +visual
+conceal           +linebreak         +python3           +visualextra
+cryptv            +lispindent        +quickfix          +viminfo
+cscope            +listcmds          +reltime           +vreplace
+cursorbind        +localmap          +rightleft         +wildignore
+cursorshape       +lua               +ruby              +wildmenu
+dialog_con        +menu              +scrollbind        +windows
+diff              +mksession         +signs             +writebackup
+digraphs          +modify_fname      +smartindent       -X11
-dnd               +mouse             -sound             -xfontset
-ebcdic            -mouseshape        +spell             -xim
+emacs_tags        +mouse_dec         +startuptime       -xpm
+eval              -mouse_gpm         +statusline        -xsmp
+ex_extra          -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+extra_search      +mouse_netterm     +syntax            -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -lintl -framework AppKit  -L/usr/local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.15 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.32.0/lib/perl5/5.32.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/config-3.8-darwin -lpython3.8 -framework CoreFoundation  -lruby.2.7

Output of YcmDebugInfo

Printing YouCompleteMe debug information...
-- Resolve completions: Up front
-- Client logfile: /var/folders/vr/q2r0ll7j3zzbkfjtkrvk9m2r0000gn/T/ycm_xlv25cq4.log
-- Server Python interpreter: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3
-- Server Python version: 3.8.5
-- Server has Clang support compiled in: True
-- Clang version: clang version 10.0.0
-- No extra configuration file found
-- Python completer debug information:
--   Python interpreter: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3
--   Python root: /Users/siiyrang/Documents/project/HomeWork/CV assigment2
--   Python path: ['/Users/siiyrang/Github/PaddleDetection', '/Users/siiyrang/Documents/project/HomeWork/CV assigment2', '/Lib
rary/Frameworks/Python.framework/Versions/3.8/lib/python38.zip', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python
3.8', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload', '/Users/siiyrang/Library/Python/3.8/lib/p
ython/site-packages', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages']
--   Python version: 3.8.5
--   Jedi version: 0.17.2
--   Parso version: 0.7.1
-- Server running at: http://127.0.0.1:61571
-- Server process ID: 35161
-- Server logfiles:
--   /var/folders/vr/q2r0ll7j3zzbkfjtkrvk9m2r0000gn/T/ycmd_61571_stdout_ryksfhbs.log
--   /var/folders/vr/q2r0ll7j3zzbkfjtkrvk9m2r0000gn/T/ycmd_61571_stderr_i9qugv7b.log

Output of YcmDiags

No warnings or error detected.

Output of git rev-parse HEAD in YouCompleteMe installation directory

paste output here

vimrc_ycm_minimal

" windows default encoding is not supported set encoding=utf-8

" If you using neovim and python isn't loading, copy your python setup from your " vimrc here: " " let g:python3_host_prog = '/path/to/python3/with/neovim/module' " " But remember that neovim is not officially supported, so please reproduce in " Vim.

" Enable debugging let g:ycm_keep_logfiles = 1 let g:ycm_log_level = 'debug'

" If the base settings don't repro, paste your existing config for YCM only, " here: " let g:ycm_....

" Load YCM (only) let &rtp .= ',' . expand( ':p:h' ) filetype plugin indent on

Contents of YCM, ycmd and completion engine logfiles

Traceback (most recent call last): File "/Users/siiyrang/.vim/bundle/YouCompleteMe/python/ycm/client/base_request.py", line 73, in HandleFuture return _JsonFromFuture( future ) File "/Users/siiyrang/.vim/bundle/YouCompleteMe/python/ycm/client/base_request.py", line 256, in _JsonFromFuture raise MakeServerException( response.json() ) ycmd.responses.ServerError: RuntimeError: Can't jump to definition.

Reproduce the issue with vim -Nu /path/to/YCM/vimrc_ycm_minimal, which enabled debug logging and other useful diagnostics. Include a link to a gist containing all of the log files listed by :YcmToggleLogs.

OS version, distribution, etc.

macOS 10.15.7

Output of build/install commands

when I input, ":YcmCompleter GoTodefiniton"

there show,RuntimmError: Can't jump to definition

Include link to a gist containing the invocation and entire output of install.py if reporting an installation issue.

puremourning commented 3 years ago

You need to produce a minimal reproducible test case. I assume that it's simply that Jedi can't find any definitions for the identifier, but from what you've set, it's very hard to tell what we can do about this.

tricomm commented 3 years ago

You need to produce a minimal reproducible test case. I assume that it's simply that Jedi can't find any definitions for the identifier, but from what you've set, it's very hard to tell what we can do about this. there is a simple test case text.py is follow

import cv2 import numpy print("sad") cv2.addText() numpy.amax()

when I input :YcmCompleter GoTodefinition for "cv2", "numpy", "print", "addText" and "amax" everything is correct, but except the addText(). for addText() it log a error “RuntimmError: Can't jump to definition”. actually I can't jump every function in opencv(cv2) but when keep my cursor on the cv2's function I can see the doc file and the command ":YcmCompleter GetDoc "is work well.

bstaletic commented 3 years ago

This isn't a YCM issue, but a jedi issue. Here's what's happening:

import jedi
script = jedi.Script('import cv2;cv2.addText')
definitions = script.goto(line=1, column=18)
assert definitions == 1
definition = definitons[0]
assert definition.module_path is None
assert definition.line is None
assert definition.column is None
tricomm commented 3 years ago

This isn't a YCM issue, but a jedi issue. Here's what's happening:

import jedi
script = jedi.Script('import cv2;cv2.addText')
definitions = script.goto(line=1, column=18)
assert definitions == 1
definition = definitons[0]
assert definition.module_path is None
assert definition.line is None
assert definition.column is None

Can you gave some suggestion? how to solve jedi issue

bstaletic commented 3 years ago

By opening an issue in jedi's repo.

tricomm commented 3 years ago

By opening an issue in jedi's repo.

Thank you~