Python support not working when activating alternative python version in shell

13 views
Skip to first unread message

Rik

unread,
Aug 30, 2022, 12:05:37 PM8/30/22
to SpaceVim
I have a strange problem regarding Python, asdf-vm and SpaceVim. It doesn't happen with plain Neovim.

When I use asdf-vm to activate a different Python version in my shell than is configured in the `g:python3_host_prog` and `python_interpreter` options, the output of `:echo has("python3")` is `0` instead of `1`.

--------------

To reproduce:

1. Install asdf-vm

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.2
. $HOME/.asdf/asdf.sh # add to bashrc to load automatically
. $HOME/.asdf/completions/asdf.bash # add to bashrc to load automatically


2. Install 2 python versions with asdf-vm

asdf install python 3.10.6
asdf install python 3.10.4


3. Configure these config files for SpaceVim:

# .SpaceVim.d/init.toml

[options]
    bootstrap_before = 'myspacevim#before'
    bootstrap_after = 'myspacevim#after'

[[layers]]
    name = 'lang#python'
    python_interpreter = '~/.asdf/installs/python/3.10.6/bin/python'


# .SpaceVim.d/autoload/myspacevim.vim

function! myspacevim#before() abort
    let g:python3_host_prog = '/home/rik/.asdf/installs/python/3.10.6/bin/python'
endfunction

function! myspacevim#after() abort
endfunction


4. Activate Python 3.10.6 in the shell:

asdf shell python 3.10.6

5. Install pip package `pynvim` for this Python installation:

pip install pynvim

6. Start `nvim` and execute `:echo has("python3")`.

It should output `1`

7. Activate Python 3.10.4 in the shell:

asdf shell python 3.10.4

8. Start `nvim` and execute `:echo has("python3")`.

It outputs `0`, which is the problem.

----------------

Now to compare it to starting Neovim without Spacevim config:

1. Create a test vimrc file:

# ~/.nvimtest.vim
let g:python3_host_prog = '/home/rik/.asdf/installs/python/3.10.6/bin/python'


2. Start Neovim with this RC file:

nvim -u ~/.nvimtest.vim

3. Execute `:echo has("python3")`.

Now it should return `1` again. For whichever Python version you activated in the shell with asdf-vm.

Btw, the output of my `:checkhealth` is in all situations the same:

## Python 3 provider (optional)
  - INFO: Using: g:python3_host_prog = "/home/rik/.asdf/installs/python/3.10.6/bin/python"
  - INFO: Executable: /home/rik/.asdf/installs/python/3.10.6/bin/python
  - INFO: Python version: 3.10.6
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

Only the `:echo has("python3")` is different between SpaceVim and Neovim, when nvim is started in a shell where an alternative python version was activated with asdf-vm.

And if I enable Denite in `.SpaceVim.d/init.toml`:

[[layers]]
    name = "denite"


Then this layer is not activated in the shell where `:echo has("python3")` returns `0`. You can check it by checking whether the `:Denite` command is available.

So this seems like a bug in SpaceVim. Or am I missing something?
Reply all
Reply to author
Forward
0 new messages