aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-core
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2025-07-25 09:54:47 +0200
committerGitHub <noreply@github.com>2025-07-25 09:54:47 +0200
commitedd8f7bce8f86465349b24e235718eb3ea52878d (patch)
tree71ed79f104c3f89a222c5d2068d049e68353fd4b /lua/mason-core
parentfix(fetch): add busybox wget support (#1829) (diff)
downloadmason-edd8f7bce8f86465349b24e235718eb3ea52878d.tar
mason-edd8f7bce8f86465349b24e235718eb3ea52878d.tar.gz
mason-edd8f7bce8f86465349b24e235718eb3ea52878d.tar.bz2
mason-edd8f7bce8f86465349b24e235718eb3ea52878d.tar.lz
mason-edd8f7bce8f86465349b24e235718eb3ea52878d.tar.xz
mason-edd8f7bce8f86465349b24e235718eb3ea52878d.tar.zst
mason-edd8f7bce8f86465349b24e235718eb3ea52878d.zip
fix(spawn): fix locating exepath on Windows systems using a Unix `'shell'` (#1991)
Fixes #1961.
Diffstat (limited to 'lua/mason-core')
-rw-r--r--lua/mason-core/spawn.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/lua/mason-core/spawn.lua b/lua/mason-core/spawn.lua
index 038d7853..d604dfe2 100644
--- a/lua/mason-core/spawn.lua
+++ b/lua/mason-core/spawn.lua
@@ -13,6 +13,21 @@ local spawn = {
_flatten_cmd_args = _.compose(_.filter(is_not_nil), _.flatten),
}
+---@param cmd string
+local function exepath(cmd)
+ if platform.is.win then
+ -- On Windows, exepath() assumes the system is capable of executing "Unix-like" executables if the shell is a Unix
+ -- shell. We temporarily override it to a Windows shell ("powershell") to avoid that behaviour.
+ local old_shell = vim.o.shell
+ vim.o.shell = "powershell"
+ local expanded_cmd = vim.fn.exepath(cmd)
+ vim.o.shell = old_shell
+ return expanded_cmd
+ else
+ return vim.fn.exepath(cmd)
+ end
+end
+
local function Failure(err, cmd)
return Result.failure(setmetatable(err, {
__tostring = function()
@@ -67,7 +82,7 @@ setmetatable(spawn, {
-- in PATH.
if platform.is.win and (spawn_args.env and has_path(spawn_args.env)) == nil then
a.scheduler()
- local expanded_cmd = vim.fn.exepath(canonical_cmd)
+ local expanded_cmd = exepath(canonical_cmd)
if expanded_cmd ~= "" then
cmd = expanded_cmd
end