neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Other
24.43k stars 954 forks source link

Coc.nvim broke with scoop install python. #3623

Closed hungpham3112 closed 2 years ago

hungpham3112 commented 2 years ago

Step to reproduce:

Window:

  1. scoop install python and scoop install vim
  2. Minimal vimrc: call plug#begin('~/vimfiles/plugged') Plug 'https://github.com/neoclide/coc.nvim.git' call plug#end()
  3. see the error

You can see more in here and here

chemzqm commented 2 years ago

What error? Please provide the error shown in vim.

hungpham3112 commented 2 years ago
 [Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python'
  isolated = 0iles\vimrc
  environment = 1s\install.bat
  user site = 1ject\effective_c\hello.c
  import site = 1ct\effective_c\hello.exe
  sys._base_executable = 'C:\\Users\\hungpham\\scoop\\apps\\vim-nightly\\current\\vim.exe'
  sys.base_prefix = 'C:\\Users\\hungpham\\scoop\\apps\\python\\current'
  sys.base_exec_prefix = 'C:\\Users\\hungpham\\scoop\\apps\\python\\current'
  sys.platlibdir = 'lib'rShell\Microsoft.PowerShell_profile.ps1
  sys.executable = 'C:\\Users\\hungpham\\scoop\\apps\\vim-nightly\\current\\vim.exe'
  sys.prefix = 'C:\\Users\\hungpham\\scoop\\apps\\python\\current'              dos  utf-8  startify   34%   15:5
  sys.exec_prefix = 'C:\\Users\\hungpham\\scoop\\apps\\python\\current'
  sys.path = [
    'C:\\Users\\hungpham\\scoop\\apps\\python\\current\\python310.zip',
    'C:\\Users\\hungpham\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\',
    'C:\\Users\\hungpham\\AppData\\Local\\Programs\\Python\\Python310\\DLLs\\',
    'C:\\Python310\\Lib\\',
    'C:\\Python310\\DLLs\\',
    'C:\\Users\\hungpham\\scoop\\apps\\vim-nightly\\current',
  ]
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 0x000035a4 (most recent call first):
  <no Python frame>

here is the error. Did you try to see 2 link I give to you?

chemzqm commented 2 years ago

It's not likely caused by coc.nvim itself since it has nothing to do with your python. Should be python issue with your vim, try uninstall coc-snippets which using python code or use let $COC_NO_PLUGINS = '1' in your vimrc to disable all extensions of coc.nvim.

chemzqm commented 2 years ago

Use command like :pyx print(3) should reproduce the issue.

hungpham3112 commented 2 years ago

It's not likely caused by coc.nvim itself since it has nothing to do with your python. Should be python issue with your vim, try uninstall coc-snippets which using python code or use let $COC_NO_PLUGINS = '1' in your vimrc to disable all extensions of coc.nvim.

This work to me, no error show after use let $COC_NO_PLUGINS = '1'. But :pyx print(3) still raise the error. So what's happening in here? It's caused by vim?

yaegassy commented 2 years ago

@hungpham3112 In coc-snippets, there is code that uses :pyx because of its ability to work with Ultisnips, so it will cause an error, but your Vim8 is causing the error with the :pyx command in the first place.

Another Vim plugin that uses :pyx will probably give you the same error

This is not a problem with coc-snippets.

hungpham3112 commented 2 years ago

@hungpham3112 In coc-snippets, there is code that uses :pyx because of its ability to work with Ultisnips, so it will cause an error, but your Vim8 is causing the error with the :pyx command in the first place.

Another Vim plugin that uses :pyx will probably give you the same error

This is not a problem with coc-snippets.

How to solve this problem?

yaegassy commented 2 years ago

How to solve this problem?

I don't use Windows, so I don't know, but if you install vim and python in a way other than scoop, for example, you might be able to isolate the problem!

chemzqm commented 2 years ago

Compile your vim with python you've just installed should help.

yaegassy commented 2 years ago

@hungpham3112 Please track https://github.com/vim/vim/pull/9710

giggio commented 2 years ago

I was able to work around this problem by setting the PYTHONHOME environment variable, like so (on cmd, adapt for poweshell etc):

set PYTHONHOME=C:\Users\giovanni\scoop\apps\python39\current\ 

I'm not sure why this is happening, but it fixed it for now.

I'm on the same setup, vim and python installed through scoop. I got the exact same error.

The :pyx print(3) was a good test, it crashed immediately with the same error. The let $COC_NO_PLUGINS = '1' also fixed it temporarily, so I could run vim without issues and test the waters.

hungpham3112 commented 2 years ago

I was able to work around this problem by setting the PYTHONHOME environment variable, like so (on cmd, adapt for poweshell etc):

set PYTHONHOME=C:\Users\giovanni\scoop\apps\python39\current\ 

I'm not sure why this is happening, but it fixed it for now.

I'm on the same setup, vim and python installed through scoop. I got the exact same error.

The :pyx print(3) was a good test, it crashed immediately with the same error. The let $COC_NO_PLUGINS = '1' also fixed it temporarily, so I could run vim without issues and test the waters.

See this, It's cause by the sample vimrc and gvimrc in directory when you install vim. Solved here