mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 05:28:33 +00:00
fix(health): errors in :checkhealth with pyenv-virtualenv #35865
Problem: pyenv-virtualenv sets a different path for VIRTUAL_ENV than the path to the python binary it provides, but these paths both symlink to the same file, so there should be no disparity. The python health-check reports an error, since it only checks if these paths are equal, not where they point to (resolve to). Solution: - Resolve the python symlinks before checking if they are equal. - Deduplicate some code.
This commit is contained in:
@@ -805,27 +805,32 @@ local function python()
|
|||||||
local nvim_py_bin = python_exepath(vim.fn.exepath(py_bin_basename))
|
local nvim_py_bin = python_exepath(vim.fn.exepath(py_bin_basename))
|
||||||
if nvim_py_bin then
|
if nvim_py_bin then
|
||||||
local subshell_py_bin = python_exepath(py_bin_basename)
|
local subshell_py_bin = python_exepath(py_bin_basename)
|
||||||
if venv_bin ~= nvim_py_bin then
|
local bintable = {
|
||||||
errors[#errors + 1] = '$PATH yields this '
|
['nvim'] = {
|
||||||
.. py_bin_basename
|
['path'] = nvim_py_bin,
|
||||||
.. ' executable: '
|
['hint'] = '$PATH ambiguities arise if the virtualenv is not '
|
||||||
.. nvim_py_bin
|
.. 'properly activated prior to launching Nvim. Close Nvim, activate the virtualenv, '
|
||||||
local hint = '$PATH ambiguities arise if the virtualenv is not '
|
.. 'check that invoking Python from the command line launches the correct one, '
|
||||||
.. 'properly activated prior to launching Nvim. Close Nvim, activate the virtualenv, '
|
.. 'then relaunch Nvim.',
|
||||||
.. 'check that invoking Python from the command line launches the correct one, '
|
},
|
||||||
.. 'then relaunch Nvim.'
|
['subshell'] = {
|
||||||
hints[hint] = true
|
['path'] = subshell_py_bin,
|
||||||
end
|
['hint'] = '$PATH ambiguities in subshells typically are '
|
||||||
if venv_bin ~= subshell_py_bin then
|
.. 'caused by your shell config overriding the $PATH previously set by the '
|
||||||
errors[#errors + 1] = '$PATH in subshells yields this '
|
.. 'virtualenv. Either prevent them from doing so, or use this workaround: '
|
||||||
.. py_bin_basename
|
.. 'https://vi.stackexchange.com/a/34996',
|
||||||
.. ' executable: '
|
},
|
||||||
.. subshell_py_bin
|
}
|
||||||
local hint = '$PATH ambiguities in subshells typically are '
|
for bintype, bin in pairs(bintable) do
|
||||||
.. 'caused by your shell config overriding the $PATH previously set by the '
|
if vim.fn.resolve(venv_bin) ~= vim.fn.resolve(bin['path']) then
|
||||||
.. 'virtualenv. Either prevent them from doing so, or use this workaround: '
|
local type_of_path = bintype == 'subshell' and '$PATH' or '$PATH in subshell'
|
||||||
.. 'https://vi.stackexchange.com/a/34996'
|
errors[#errors + 1] = type_of_path
|
||||||
hints[hint] = true
|
.. ' yields this '
|
||||||
|
.. py_bin_basename
|
||||||
|
.. ' executable: '
|
||||||
|
.. bin['path']
|
||||||
|
hints[bin['hint']] = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user