-
Notifications
You must be signed in to change notification settings - Fork 788
fix(command_resolver): fix resolve executable on Windows system #1341
base: main
Are you sure you want to change the base?
Conversation
@@ -1,6 +1,6 @@ | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can we actually add this to our path utils and read the value from there? I'd rather avoid duplicating the check.
@@ -46,7 +46,12 @@ end | |||
M.from_node_modules = function() | |||
local node_modules_resolver = M.generic(u.path.join("node_modules", ".bin")) | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two potential issues with this:
- I'm not sure if mutating this directly on the
params
table will have any unexpected effects, but it seems risky. - If we're looking for
eslint
and don't find a local executable, then we'll be looking foreslint.cmd
in$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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
end This 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