Skip to content
This repository was archived by the owner on Oct 6, 2024. It is now read-only.
This repository was archived by the owner on Oct 6, 2024. It is now read-only.

"Undefined variable: g:python3_host_prog" on non-Neovim installation #49

@itaiferber

Description

@itaiferber

Launching MacVim with pathfinder.vim installed complains about g:python3_host_prog not being found:

Error detected while processing /Users/itai/.dotfiles/vim/.vim/bundle/pathfinder.vim/plugin/main.vim:
line   27:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/itai/.dotfiles/vim/.vim/bundle/pathfinder.vim/pathfinder/client/plugin.py", line 15, in __init__
    self.client = Client()
  File "/Users/itai/.dotfiles/vim/.vim/bundle/pathfinder.vim/pathfinder/client/client.py", line 24, in __init__
    self.open()
  File "/Users/itai/.dotfiles/vim/.vim/bundle/pathfinder.vim/pathfinder/client/client.py", line 34, in open
    self._build_server_cmd(), stdout=subprocess.PIPE, stderr=subprocess.PIPE
  File "/Users/itai/.dotfiles/vim/.vim/bundle/pathfinder.vim/pathfinder/client/client.py", line 43, in _build_server_cmd
    python3_host_prog = vim.eval("g:python3_host_prog")
vim.error: Vim:E121: Undefined variable: g:python3_host_prog
Press ENTER or type command to continue

Interestingly, this line is only supposed to be hit if nvim is present:

    def _build_server_cmd(self):
        """Build the command used to launch the server Vim."""
        if vim.eval("has('nvim')"):
            python3_host_prog = vim.eval("g:python3_host_prog")
            options = [
                "--headless",
                "--cmd",
                f"let g:python3_host_prog='{python3_host_prog}'",
            ]
        else:
            options = ["-v", "--not-a-term"]

However, I'm not in Neovim, and both :echo has('nvim') and :py3 print(vim.eval("has('nvim')")) print 0. I'm not sure what could cause vim.eval("has('nvim')") to evaluate to a truthy value especially since executing the same test manually doesn't replicate that value.

It's not exactly g:python3_host_prog itself that's an issue, because even if I manually define it, pathfinder.vim is setting options in order to launch a Neovim instance, and regular vim doesn't recognize --headless. Any idea what might be causing this? Would it make sense to inspect v:progpath instead of has('nvim') because that's what eventually gets launched anyway? (Changing the condition to if vim.eval("has('nvim')" == 1: resolves the issue of course, but this seems hacky since 0 should be falsy anyway, right?)


Vim version (expand for features):
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Dec  3 2020 11:33:19)
macOS version
Included patches: 1-1719
Compiled by Homebrew
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl               +file_in_path      -mouse_sysmouse    -tag_old_static
+arabic            +find_in_path      +mouse_urxvt       -tag_any_white
+autocmd           +float             +mouse_xterm       +tcl
+autochdir         +folding           +multi_byte        +termguicolors
-autoservername    -footer            +multi_lang        +terminal
+balloon_eval      +fork()            -mzscheme          +terminfo
+balloon_eval_term +fullscreen        +netbeans_intg     +termresponse
+browse            +gettext           +num64             +textobjects
++builtin_terms    -hangul_input      +odbeditor         +textprop
+byte_offset       +iconv             +packages          +timers
+channel           +insert_expand     +path_extra        +title
+cindent           +ipv6              +perl              +toolbar
+clientserver      +job               +persistent_undo   +transparency
+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_gui    +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
-farsi             +mouse_sgr         +tag_binary
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector-strong -L/Users/itai/Homebrew/lib -L/Users/itai/Homebrew/opt/libyaml/lib -L/Users/itai/Homebrew/opt/openssl@1.1/lib -L/Users/itai/Homebrew/opt/readline/lib -L. -fstack-protector-strong -L/Users/itai/Homebrew/lib -L/Users/itai/Homebrew/opt/libyaml/lib -L/Users/itai/Homebrew/opt/openssl@1.1/lib -L/Users/itai/Homebrew/opt/readline/lib  -L/Users/itai/Homebrew/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv /Users/itai/Homebrew/lib/libintl.a -framework AppKit  -L/Users/itai/Homebrew/opt/lua/lib -llua5.4 -fstack-protector-strong  -L/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE -lperl  -L/Users/itai/Homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/config-3.9-darwin -lpython3.9 -lintl -framework CoreFoundation -F/System/Library/Frameworks -framework Tcl -framework CoreFoundation -lruby.2.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working properly

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions