fix(command_resolver): fix resolve executable on Windows system#1341
fix(command_resolver): fix resolve executable on Windows system#1341IronLu233 wants to merge 4 commits intojose-elias-alvarez:mainfrom
Conversation
| local cache = require("null-ls.helpers.cache") | ||
| local u = require("null-ls.utils") | ||
|
|
||
| local is_windows = vim.loop.os_uname().version:match("Windows") |
There was a problem hiding this comment.
Nit: can we actually add this to our path utils and read the value from there? I'd rather avoid duplicating the check.
| return function(params) | ||
| return node_modules_resolver(params) or params.command | ||
| if is_windows then | ||
| params.command = params.command .. ".cmd" |
There was a problem hiding this comment.
Two potential issues with this:
- I'm not sure if mutating this directly on the
paramstable will have any unexpected effects, but it seems risky. - If we're looking for
eslintand don't find a local executable, then we'll be looking foreslint.cmdin$PATH(I'm actually not sure what this will do, but I suspect it won't work).
I think it would be less risky to declare local command_to_find = params.command and use that, then fall back to params.command.
|
Manually, I test two cases:
|
|
I rebased the PR to fix CI and also removed
Based on your comment, my understanding is that with these changes, we can still fall back to the global |
|
I don't really know about Windows shells, but is neovim/neovim#21175 related to this at all? |
Hi, I tested those changes, it worked well for current situation. But I also have some concerns:
|
|
If I understand the original issue correctly: it looks like the null-ls command resolver does correctly find local binaries when they're available, but spawning then fails because the path lacks the diff --git a/lua/null-ls/helpers/command_resolver.lua b/lua/null-ls/helpers/command_resolver.lua
index e1d1ab2..89d85d7 100644
--- a/lua/null-ls/helpers/command_resolver.lua
+++ b/lua/null-ls/helpers/command_resolver.lua
@@ -45,11 +45,10 @@ end
M.from_node_modules = function()
local node_modules_resolver = M.generic(u.path.join("node_modules", ".bin"))
return function(params)
- if u.path.is_windows then
+ local resolved_executable = node_modules_resolver(params)
+ if resolved_executable and u.path.is_windows then
params.command = params.command .. ".cmd"
end
-
- local resolved_executable = node_modules_resolver(params)
return resolved_executable or params.command
end
endThis would avoid the mutation issue but I'm not sure it'll work. |
|
I'm still having a hard time understanding the behavior of |


fix #1118