Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python resolution order does not respect PATH #1748

Closed
3 tasks done
VRehnberg opened this issue Jul 3, 2024 · 3 comments · Fixed by #1736
Closed
3 tasks done

Python resolution order does not respect PATH #1748

VRehnberg opened this issue Jul 3, 2024 · 3 comments · Fixed by #1736

Comments

@VRehnberg
Copy link

I've searched open issues for similar requests

  • Yes

I've manually reviewed logs to find potential errors

  • Yes

I've recently downloaded the latest plugin version of mason.nvim

  • Yes

Problem description

From a conda environment with Python 3.9.17 (picked up by :checkhealth mason) pypi installer picks up and uses system python version 3.10. Output from MasonLog:

[INFO  ons  3 jul 2024 11:11:01] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:184: Executing installer for Package(name=ruff-lsp) {}
[ERROR ons  3 jul 2024 11:11:01] ...e/nvim/lazy/mason.nvim/lua/mason-core/installer/init.lua:249: Installation failed for Package(name=ruff-lsp) error=spawn: python3.10 failed with exit code 1 and signal 0. 

Expected behavior

PATH should be respected. It looks like the culprit is [resolve_python3](https://github.com/williamboman/mason.nvim/blob/main/lua/mason-core/installer/managers/pypi.lua#L20-L33)() and probably the call for versioned candidates at https://github.com/williamboman/mason.nvim/blob/main/lua/mason-core/installer/managers/pypi.lua#L91

Instead of taking the python resolved by PATH it picks the latest python version that is supported.

Steps to reproduce

  1. Create a conda virtual environment with a supported Python version older than the system one
  2. Set PATH="append" (or "skip"):
{
    "williamboman/mason.nvim",
    config = function()
      require('mason').setup({
        PATH = "append",
      })
    end
}
  1. Open python file with Neovim (might need some python lsp neovim package as well, not sure what is telling mason to install ruff-lsp)

Affected packages

ruff-lsp

Neovim version (>= 0.7)

NVIM v0.10.0
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068

Operating system/version

Linux c3se-TP6 6.5.0-41-generic #41~22.04.2-Ubuntu SMP PREEMPT_DYNAMIC Mon Jun 3 11:32:55 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Healthcheck

==============================================================================
mason: require("mason.health").check()

mason.nvim ~
- OK mason.nvim version v1.10.0
- OK PATH: append
- OK Providers: 
    mason.providers.registry-api
    mason.providers.client
- OK neovim version >= 0.7.0

mason.nvim [Registries] ~
- OK Registry `github.com/mason-org/mason-registry version: 2024-07-02-cyan-tub` is installed.

mason.nvim [Core utils] ~
- OK unzip: `UnZip 6.00 of 20 April 2009, by Debian. Original by Info-ZIP.`
- OK wget: `GNU Wget 1.21.2 built on linux-gnu.`
- OK curl: `curl 7.81.0 (x86_64-pc-linux-gnu) libcurl/7.81.0 OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.17`
- OK gzip: `gzip 1.10`
- OK tar: `tar (GNU tar) 1.34`
- OK bash: `GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)`
- OK sh: `Ok`

mason.nvim [Languages] ~
- WARNING Go: not available
  - ADVICE:
    - spawn: go failed with exit code - and signal -. go is not executable
- WARNING cargo: not available
  - ADVICE:
    - spawn: cargo failed with exit code - and signal -. cargo is not executable
- WARNING luarocks: not available
  - ADVICE:
    - spawn: luarocks failed with exit code - and signal -. luarocks is not executable
- WARNING Ruby: not available
  - ADVICE:
    - spawn: ruby failed with exit code - and signal -. ruby is not executable
- WARNING RubyGem: not available
  - ADVICE:
    - spawn: gem failed with exit code - and signal -. gem is not executable
- WARNING Composer: not available
  - ADVICE:
    - spawn: composer failed with exit code - and signal -. composer is not executable
- WARNING PHP: not available
  - ADVICE:
    - spawn: php failed with exit code - and signal -. php is not executable
- WARNING javac: not available
  - ADVICE:
    - spawn: javac failed with exit code - and signal -. javac is not executable
- WARNING java: not available
  - ADVICE:
    - spawn: java failed with exit code - and signal -. java is not executable
- WARNING julia: not available
  - ADVICE:
    - spawn: julia failed with exit code - and signal -. julia is not executable
- OK python: `Python 3.9.17`
- OK node: `v18.16.0`
- OK pip: `pip 24.0 from /home/vikren/miniconda3/envs/ds/lib/python3.9/site-packages/pip (python 3.9)`
- OK python venv: `Ok`
- OK npm: `9.5.1`

mason.nvim [GitHub] ~
- OK GitHub API rate limit. Used: 0. Remaining: 60. Limit: 60. Reset: ons  3 jul 2024 12:49:17.
  Install and authenticate via gh-cli to increase rate limit.

Screenshots or recordings

No response

@VRehnberg
Copy link
Author

A quick fix for me was to modify https://github.com/williamboman/mason.nvim/blob/main/lua/mason-core/installer/managers/pypi.lua#L91:

-    local target = resolve_python3(versioned_candidates) or stock_target
+    local target = stock_target

@VRehnberg
Copy link
Author

My suggested solution would be to just use stock_target and check if it is compatible. If isn't, throw an error and exit rather than trying to use a non-default python. (But, that could be a breaking change for those that rely on the old behaviour).

@williamboman
Copy link
Owner

Should be fixed in #1736. Note that it will only use the python3 executable in PATH if it satisfies the python version requirement (if specified by the package).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

2 participants