mason.nvim icon indicating copy to clipboard operation
mason.nvim copied to clipboard

fix: python health check problem in windows

Open zalgo3 opened this issue 2 years ago • 3 comments
trafficstars

On my Windows 11, when I run :healthcheck mason, :MasonLog says the following:

Failed to spawn process. cmd="path/to/python3", err="ENOENT: no such file or directory"

Generally, the python executable on Windows is a .bat file, and I am guessing that the program cannot find it. So, I have added a conditional branch like if platform.is.win then ... else ... end. Could you review it?

zalgo3 avatar Dec 03 '22 13:12 zalgo3

@williamboman Thank you for reviewing!

What are you using to manage python?

I use pyenv and my python is installed in %USERPROFILE%\.pyenv\pyenv-win\shims\python.bat.

Also, should the .bat vs .exe actually be an issue we'd have to revisit more things than just the healthcheck.

I feel you are right that it is not just a health check issue. The ideal solution would be to try the extensions registered in %PATHEXT%, as Windows actually does, but this may be a problem to be fixed on the libuv side. I found that alias is defined in mason-core/spawn.lua for programs that may have .bat or .cmd, so I suggest adding python there in https://github.com/williamboman/mason.nvim/pull/720/commits/d912fa9b4c1f25dd84f65ba22b7adb219aac0455.

zalgo3 avatar Dec 08 '22 10:12 zalgo3

Cool! Unfortunately this will break for Windows users who don't use pyenv. We'll need to do this slightly differently. I've been wanting to get rid of that alias table and replace it with simply calling Neovim's exepath() (which fully respects PATHEXT) to expand the executable, let me provide an alternative solution

williamboman avatar Dec 08 '22 13:12 williamboman

@williamboman Thanks!

I've been wanting to get rid of that alias table and replace it with simply calling Neovim's exepath() (which fully respects PATHEXT) to expand the executable, let me provide an alternative solution.

Is your solution like this? https://github.com/williamboman/mason.nvim/blob/08089ec168669076e0ebe861b31a3e114e055200/lua/mason-core/spawn.lua#L81-L88

zalgo3 avatar Dec 09 '22 00:12 zalgo3

https://github.com/williamboman/mason.nvim/pull/773 fixes this PR.

zalgo3 avatar Dec 20 '22 08:12 zalgo3