nixprime / cpsm

A CtrlP matcher, specialized for paths.
Apache License 2.0
202 stars 19 forks source link

No results in PY3 mode when in a venv #26

Closed svenstaro closed 8 years ago

svenstaro commented 8 years ago

I'm running neovim aliased to vim. I'm on Arch Linux where Python 3 is in /usr/bin/python and Python 2 is in /usr/bin/python2. When I compile cpsm it correctly detects Python 3 support (it echos that to me during build time).

Everything actually works fine and results shows unless I open a vim while my shell is in a venv that I created and activated like this:

pyvenv venv; source venv/bin/activate

The problem is that vim with ctrlp doesn't show any results inside of the venv. If I compile cpsm with PY3=OFF then everything works fine even in the venv.

svenstaro commented 8 years ago

After further investigation, I think it would be a good fix to not use the first python from path but instead always use the one this was compiled with.

nixprime commented 8 years ago

Can you clarify?

Do you mean the cpsm build process should use a different version of Python, as specified by vim? neovim doesn't provide any useful information here:

$ nvim --version
NVIM 0.1.5-dev
Build type: RelWithDebInfo
Compilation: /usr/bin/x86_64-linux-gnu-gcc -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -DDISABLE_LOG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -DHAVE_CONFIG_H -D_GNU_SOURCE -I/build/neovim-fdHw4I/neovim-0.1.4ubuntu1+git201608151559+2711+20~ubuntu16.04.1/build/config -I/build/neovim-fdHw4I/neovim-0.1.4ubuntu1+git201608151559+2711+20~ubuntu16.04.1/src -I/build/neovim-fdHw4I/neovim-0.1.4ubuntu1+git201608151559+2711+20~ubuntu16.04.1/.deps/usr/include -I/build/neovim-fdHw4I/neovim-0.1.4ubuntu1+git201608151559+2711+20~ubuntu16.04.1/.deps/usr/include -I/build/neovim-fdHw4I/neovim-0.1.4ubuntu1+git201608151559+2711+20~ubuntu16.04.1/.deps/usr/include -I/build/neovim-fdHw4I/neovim-0.1.4ubuntu1+git201608151559+2711+20~ubuntu16.04.1/.deps/usr/include -I/build/neovim-fdHw4I/neovim-0.1.4ubuntu1+git201608151559+2711+20~ubuntu16.04.1/.deps/usr/include -I/build/neovim-fdHw4I/neovim-0.1.4ubuntu1+git201608151559+2711+20~ubuntu16.04.1/.deps/usr/include -I/usr/include -I/build/neovim-fdHw4I/neovim-0.1.4ubuntu1+git201608151559+2711+20~ubuntu16.04.1/build/src/nvim/auto -I/build/neovim-fdHw4I/neovim-0.1.4ubuntu1+git201608151559+2711+20~ubuntu16.04.1/build/include
Compiled by buildd@lgw01-27

Optional features included (+) or not (-): +acl   +iconv    +jemalloc +tui      
For differences from Vim, see :help vim-differences

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Or do you mean Vim should use a different Python? I don't think we have any control of this from Vimscript.

svenstaro commented 8 years ago

Well I don't really know how this works. I thought one could override the Python interpreter. I just noticed that cpsm breaks inside of a virtualenv if it was built outside of the virtualenv.

nixprime commented 8 years ago

Can you do :echo has('python3') from neovim started from inside the virtualenv? If it's 0, i.e. neovim loses Python 3 support when started inside a virtualenv, there's not much cpsm can do...

From searching around, it looks like this is in fact a neovim problem. For Python 2.x, it seems that people have been working around it by setting g:python_host_prog to a fixed Python 2.x interpreter path; https://neovim.io/doc/user/provider.html indicates that the Python 3.x equivalent is g:python3_host_prog. You might want to give that a try.

svenstaro commented 8 years ago

:echo has('python') = 0 :echo has('python3') = 0

However, thanks to your great tip, I set let g:python_host_prog = '/usr/bin/python2' let g:python3_host_prog = '/usr/bin/python3'

in my vimrc and now it works properly. Looks like this is not a cpsm bug after all. Closing and thanks.