mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	fix(health): fix pyenv root and python exepath detect issue
Fix the following two issues: - pyenv root detection issue When `PYENV_ROOT` environment variable is not set, neovim will detect pyenv's root via `pyenv root` command, but which will be always fail because `vim.fn.system()` returns result with additional `\n`. Using `vim.system` instead prevents this problem. to trim it before check whether it is exists - python executable path detection issue Filter unrelated `python-config` in cases where multiple python versions are installed, e.g. `python-config`, `python3.10-config`, `python3.11-config` etc.
This commit is contained in:
		@@ -366,7 +366,17 @@ local function check_for_pyenv()
 | 
			
		||||
  local pyenv_root = vim.fn.resolve(os.getenv('PYENV_ROOT') or '')
 | 
			
		||||
 | 
			
		||||
  if pyenv_root == '' then
 | 
			
		||||
    pyenv_root = vim.fn.system({ pyenv_path, 'root' })
 | 
			
		||||
    local p = vim.system({ pyenv_path, 'root' }):wait()
 | 
			
		||||
    if p.code ~= 0 then
 | 
			
		||||
      local message = string.format(
 | 
			
		||||
        'pyenv: Failed to infer the root of pyenv by running `%s root` : %s. Ignoring pyenv for all following checks.',
 | 
			
		||||
        pyenv_path,
 | 
			
		||||
        p.stderr
 | 
			
		||||
      )
 | 
			
		||||
      health.warn(message)
 | 
			
		||||
      return { '', '' }
 | 
			
		||||
    end
 | 
			
		||||
    pyenv_root = vim.trim(p.stdout)
 | 
			
		||||
    health.info('pyenv: $PYENV_ROOT is not set. Infer from `pyenv root`.')
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@@ -754,7 +764,7 @@ local function python()
 | 
			
		||||
  local venv_bins = vim.fn.glob(string.format('%s/%s/python*', virtual_env, bin_dir), true, true)
 | 
			
		||||
  venv_bins = vim.tbl_filter(function(v)
 | 
			
		||||
    -- XXX: Remove irrelevant executables found in bin/.
 | 
			
		||||
    return not v:match('python%-config')
 | 
			
		||||
    return not v:match('python.*%-config')
 | 
			
		||||
  end, venv_bins)
 | 
			
		||||
  if vim.tbl_count(venv_bins) > 0 then
 | 
			
		||||
    for _, venv_bin in pairs(venv_bins) do
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user