diff options
| author | SkrrtBacharach <61713784+SkrrtBacharach@users.noreply.github.com> | 2025-09-21 22:25:14 +0100 |
|---|---|---|
| committer | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2025-09-21 22:06:55 +0000 |
| commit | d8a7c86e73a715d7dedf83e3e0d6255c5e5ffd75 (patch) | |
| tree | 7c457101ff2fed33c2cf3118af0ad52b722c5472 /runtime | |
| parent | c84ba83cf1a50d1f892d745c62d9dabb513f3e91 (diff) | |
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.
(cherry picked from commit cfe10b4014ec467ac8e39d4d10a87c81c982300f)
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/lua/vim/provider/health.lua | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/runtime/lua/vim/provider/health.lua b/runtime/lua/vim/provider/health.lua index 34806ec3ca..8b86119476 100644 --- a/runtime/lua/vim/provider/health.lua +++ b/runtime/lua/vim/provider/health.lua @@ -797,27 +797,32 @@ local function python() local nvim_py_bin = python_exepath(vim.fn.exepath(py_bin_basename)) if nvim_py_bin then local subshell_py_bin = python_exepath(py_bin_basename) - if venv_bin ~= nvim_py_bin then - errors[#errors + 1] = '$PATH yields this ' - .. py_bin_basename - .. ' executable: ' - .. nvim_py_bin - local hint = '$PATH ambiguities arise if the virtualenv is not ' - .. 'properly activated prior to launching Nvim. Close Nvim, activate the virtualenv, ' - .. 'check that invoking Python from the command line launches the correct one, ' - .. 'then relaunch Nvim.' - hints[hint] = true - end - if venv_bin ~= subshell_py_bin then - errors[#errors + 1] = '$PATH in subshells yields this ' - .. py_bin_basename - .. ' executable: ' - .. subshell_py_bin - local hint = '$PATH ambiguities in subshells typically are ' - .. 'caused by your shell config overriding the $PATH previously set by the ' - .. 'virtualenv. Either prevent them from doing so, or use this workaround: ' - .. 'https://vi.stackexchange.com/a/34996' - hints[hint] = true + local bintable = { + ['nvim'] = { + ['path'] = nvim_py_bin, + ['hint'] = '$PATH ambiguities arise if the virtualenv is not ' + .. 'properly activated prior to launching Nvim. Close Nvim, activate the virtualenv, ' + .. 'check that invoking Python from the command line launches the correct one, ' + .. 'then relaunch Nvim.', + }, + ['subshell'] = { + ['path'] = subshell_py_bin, + ['hint'] = '$PATH ambiguities in subshells typically are ' + .. 'caused by your shell config overriding the $PATH previously set by the ' + .. 'virtualenv. Either prevent them from doing so, or use this workaround: ' + .. 'https://vi.stackexchange.com/a/34996', + }, + } + for bintype, bin in pairs(bintable) do + if vim.fn.resolve(venv_bin) ~= vim.fn.resolve(bin['path']) then + local type_of_path = bintype == 'subshell' and '$PATH' or '$PATH in subshell' + errors[#errors + 1] = type_of_path + .. ' yields this ' + .. py_bin_basename + .. ' executable: ' + .. bin['path'] + hints[bin['hint']] = true + end end end end |
