puremourning / vimspector

vimspector - A multi-language debugging system for Vim
http://puremourning.github.io/vimspector-web
Apache License 2.0
4.13k stars 174 forks source link

E919: Directory not found in 'packpath': "pack/*/opt/vimspector" and other problems #337

Closed CharlesARoy closed 3 years ago

CharlesARoy commented 3 years ago

Describe the bug

I've been trying to get vimspector working for days now and would really appreciate some help. It looks amazing and I can't wait to use it! Basically, when I launch vim, I get the following error/warnings regarding vimspector:

Error detected while processing /Users/charles/.vimrc: line 100: E919: Directory not found in 'packpath': "pack/*/opt/vimspector"

Then when I run :call vimspector#Launch() inside VIM I get the following error:

Could not find platform independent libraries prefix Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] Python path configuration: PYTHONHOME = (not set) PYTHONPATH = (not set) program name = 'python3' isolated = 0 environment = 1 user site = 1 import site = 1 sys._base_executable = '/usr/local/bin/vim' sys.base_prefix = '/opt/concourse/worker/volumes/live/71f8613d-c53a-40aa-4c7b-351131b1952c/volume/python_1599203882312/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol' sys.base_exec_prefix = '/opt/concourse/worker/volumes/live/71f8613d-c53a-40aa-4c7b-351131b1952c/volume/python_1599203882312/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol' sys.executable = '/usr/local/bin/vim' sys.prefix = '/opt/concourse/worker/volumes/live/71f8613d-c53a-40aa-4c7b-351131b1952c/volume/python_1599203882312/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol' sys.exec_prefix = '/opt/concourse/worker/volumes/live/71f8613d-c53a-40aa-4c7b-351131b1952c/volume/python_1599203882312/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol' sys.path = [ '/opt/concourse/worker/volumes/live/71f8613d-c53a-40aa-4c7b-351131b1952c/volume/python_1599203882312/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python38.zip', '/opt/concourse/worker/volumes/live/71f8613d-c53a-40aa-4c7b-351131b1952c/volume/python_1599203882312/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python3.8', '/opt/concourse/worker/volumes/live/71f8613d-c53a-40aa-4c7b-351131b1952c/volume/python_1599203882312/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/lib-dynload', ] Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFoundError: No module named 'encodings' Current thread 0x0000000101c2fdc0 (most recent call first): no Python frame

Minimal reproduciton

Please answer the following questions

List of steps to reproduce:

  1. vim --> First bug occurs
  2. Enter
  3. :call vimspector#Launch() --> Second bug occurs

Use the following Vimspector config file:

{
  "configurations": {
    "Python: Run current script": {
      "adapter": "debugpy",
      "configuration": {
        "request": "launch",
        "program": "${file}",
        "stopOnEntry": true,
        "args": [ "*${args:--update-gadget-config}" ],
        "justMyCode#json": "${justMyCode:true}"
      }
    },
    "foobar": {}
  }
}

Expected behaviour

I expect vimspector to launch in debugging mode and look like the debugging setup in this video.

Actual behaviour

Note that this is what's in the log file but this isn't from the most recent runs with the current bugs which were run today (2021-01-08).

2021-01-07 16:37:53,650 - INFO - INITIALISING NEW VIMSPECTOR SESSION 2021-01-07 16:37:53,650 - INFO - API is: 2021-01-07 16:37:53,650 - INFO - VIMSPECTOR_HOME = /Users/charles/.vim/bundle/vimspector 2021-01-07 16:37:53,650 - INFO - gadgetDir = /Users/charles/.vim/bundle/vimspector/gadgets/macos 2021-01-07 16:37:53,650 - INFO - User requested start debug session with {} 2021-01-07 16:37:53,651 - DEBUG - Reading configurations from: None 2021-01-07 16:37:53,651 - DEBUG - Reading configurations from: None 2021-01-07 16:37:53,651 - INFO - User Msg: Unable to find any debug configurations. You need to tell vimspector how to launch your application.

  • Output from any or all UI diagnostic tabs (Server, etc.) N/A

Environemnt

/usr/local/bin/vim
zsh: no matches found: print( __import__( sys ).version )
zsh: command not found: :py3
zsh: command not found: :py3

Declaration

Please complete the following declaration. If this declaration is not completed, your issue may be closed without comment.

Additional information

From filling in this ticket it would seem that part of my issue might have to do with not having py3; however, py3 occurs zero times in the documentation. Is python3 not sufficient? This is my output when I run which -a python3

/Users/charles/anaconda3/bin/python3
/usr/local/bin/python3
/usr/bin/python3

As I was trying to fix this I came across this page that has some information regarding the python error I'm getting. However, I've tried all kinds of combination of setting and unsettling PYTHONPATH and PYTHONHOME to each of the above python installations on my computer and none of that worked. As far as I know, I'm not using any kind of virtual environments.

I have the following vimspector-related commands in my .vimrc file:

" Vim debugging
Plugin 'puremourning/vimspector'

" Vimspector key mappings
let g:vimspector_enable_mappings = 'HUMAN'

" Start vimspector at launch
packadd! vimspector

" Debugger remaps
let mapleader = ","
nnoremap <leader>m :MaximizerToggle!<CR>
nnoremap <leader>dd :call vimspector#Launch()<CR>
nnoremap <leader>dc :call GotoWindow(g:vimspector_session_windows.code)<CR>
nnoremap <leader>dt :call GotoWindow(g:vimspector_session_windows.tagpage)<CR>
nnoremap <leader>dv :call GotoWindow(g:vimspector_session_windows.variables)<CR>
nnoremap <leader>dw :call GotoWindow(g:vimspector_session_windows.watches)<CR>
nnoremap <leader>ds :call GotoWindow(g:vimspector_session_windows.stack_trace)<CR>
nnoremap <leader>do :call GotoWindow(g:vimspector_session_windows.output)<CR>
nnoremap <leader>de :call vimspector#Reset()<CR>

nnoremap <leader>dtcb :call vimspector#CleanLineBreakpoint()<CR>

nmap <leader>dl <Plug>VimspectorStepInto
nmap <leader>dj <Plug>VimspectorStepOver
nmap <leader>dk <Plug>VimspectorStepOut
nmap <leader>d_ <Plug>VimspectorRestart
nnoremap <leader>d<space> :call vimspector#Continue()<CR>

nmap <leader>drc <Plug>VimspectorRunToCursor
nmap <leader>dbp <Plug>VimspectorToggleBreakpoint
nmap <leader>dcbp <Plug>VimspectorToggleConditionalBreakpoint
puremourning commented 3 years ago

So, first, thanks for the detailed report! I and fairly sure neither of these are Vimspector bugs, based on the errors above, but as you've gone to the trouble of providing so much useful detail, I'm happy to provide support :)

Taking them in turn.

  1. E919. This simply looks like you installed it wrong (somehow). You've used Plugin (presumably vundle) to install the plugin, then used packadd! vimspector. This is wrong. packadd is only for using vim packages (read :halp packages). It's pretty clear in the docs that there are 2 different methods, and you should only use one: https://github.com/puremourning/vimspector#quick-start.

Solution: remove packadd! vimspector from your vimrc.

  1. Python errors. This looks like an open-and-shut case of your python installation is broken, or your vim's embedded python is incompatible with your python environment. Unfortunately, to prove that we need to run some of the commands in the issue template in Vim not in your shell!

Could you please run these commands from inside Vim?

That should either highlight or disprove my theory about python installation problems.

BUT: Spoiler alert, I'm willing to bet €1 that the problem is anaconda. I see that your vim seems to link against anaconda python (-L/Users/charles/anaconda3/lib/python3.8/config-3.8-darwin) which in my experience is a total nightmare of pain and suffering. Try rebuilding your vim against homebrew python, or install macvim from homebrew instead of vim.

puremourning commented 3 years ago

Also your sys paths seems very wonky. What's concourse ?

sys.base_prefix = '/opt/concourse/worker/...
puremourning commented 3 years ago

So I saw your post on vim_dev. Looks like you were having some problems building vim from source that ultimately may have related to anaconda...

I'd suggest just using hombrew vim (that's what I use!), as in brew install vim (or brew upgrade vim). You may need something like brew link --overwrite vim as it looks like your manually installed files are likely to conflict with where homebrew will want to put its symlinks. Alternatively MacVim should work just fine too (either brew install --cask macvim or install from Mac vim app bundle).

Give me a shout on Gitter if you have any further problems.

CharlesARoy commented 3 years ago

Thank you SO much for the help! This has definitely been a total nightmare of pain and suffering haha.

Ok, so when I run any of those :py3... commands in VIM, I get the same error as when I was trying to launch the debugger: Could not find platform independent libraries prefix Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] . . .

I'm not sure what's up with concourse, it's not something I installed intentionally. I can't find much on it but came across this post which is listed under "ContinuumIO/anaconda-issues", so it may be something anaconda uses.

I would probably prefer using the macvim that's already available in macOS so that I don't have to have any extra copies of vim hanging around. However, as I mentioned in that vim_dev issue the documentation for Vimspector says that you need "Vim 8.2 Huge build compiled with Python 3.6 or later" and the version of Vim that comes with mac (macvim) is 8.1 and isn't compiled with python3 seemingly.

When I tried launching vimspector in macvim, I'd get the following error: Vimspector unavailable: Requires Vim compiled with Python 3.6

Running vim --version for macvim returns:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun  5 2020 21:30:37)
macOS version
Included patches: 1-503, 505-680, 682-2292
Compiled by root@apple.com
Normal version without GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_any_white
-arabic            +file_in_path      -mouse_urxvt       -tcl
+autocmd           +find_in_path      +mouse_xterm       -termguicolors
+autochdir         +float             +multi_byte        +terminal
-autoservername    +folding           +multi_lang        +terminfo
-balloon_eval      -footer            -mzscheme          +termresponse
-balloon_eval_term +fork()            +netbeans_intg     +textobjects
-browse            -gettext           +num64             +textprop
+builtin_terms     -hangul_input      +packages          +timers
+byte_offset       +iconv             +path_extra        +title
+channel           +insert_expand     -perl              -toolbar
+cindent           +job               +persistent_undo   +user_commands
-clientserver      +jumplist          +postscript        -vartabs
+clipboard         -keymap            +printer           +vertsplit
+cmdline_compl     +lambda            -profile           +virtualedit
+cmdline_hist      -langmap           +python/dyn        +visual
+cmdline_info      +libcall           -python3           +visualextra
+comments          +linebreak         +quickfix          +viminfo
-conceal           +lispindent        +reltime           +vreplace
+cryptv            +listcmds          -rightleft         +wildignore
+cscope            +localmap          +ruby/dyn          +wildmenu
+cursorbind        -lua               +scrollbind        +windows
+cursorshape       +menu              +signs             +writebackup
+dialog_con        +mksession         +smartindent       -X11
+diff              +modify_fname      -sound             -xfontset
+digraphs          +mouse             +spell             -xim
-dnd               -mouseshape        +startuptime       -xpm
-ebcdic            -mouse_dec         +statusline        -xsmp
-emacs_tags        -mouse_gpm         -sun_workshop      -xterm_clipboard
+eval              -mouse_jsbterm     +syntax            -xterm_save
+ex_extra          -mouse_netterm     +tag_binary        
+extra_search      +mouse_sgr         -tag_old_static    
   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/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa 

For some reason when I last installed VIM with homebrew, I thought that it was also not compiled with python3, which is why I went through the whole process of compiling vim from the source with the settings you mention here.

However, I must have made a mistake somewhere because after removing the manually compiled copy of vim and installing it with brew, I was finally able to launch the debugger without getting the python error message.

TLDR For anyone reading this, these are the exact steps I took to get everything working for debugging python:

puremourning commented 3 years ago

VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 5 2020 21:30:37) macOS version Included patches: 1-503, 505-680, 682-2292 Compiled by root@apple.com

that's not MacVim, this is MacVIm: https://macvim-dev.github.io/macvim/