Skip to content

Commit 6f3853e

Browse files
authored
feat(health): add advice for Debian/Ubuntu regarding python3 venv (#1358)
1 parent ed98935 commit 6f3853e

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

lua/mason/health.lua

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ local report_error = _.scheduler_wrap(health.error or health.report_error)
2323
local sem = Semaphore.new(5)
2424

2525
---@async
26-
---@param opts {cmd:string, args:string[], name: string, use_stderr: boolean?, version_check: (fun(version: string): string?), relaxed: boolean?}
26+
---@param opts {cmd:string, args:string[], name: string, use_stderr: boolean?, version_check: (fun(version: string): string?), relaxed: boolean?, advice: string[]}
2727
local function check(opts)
2828
local get_first_non_empty_line = _.compose(_.head, _.filter(_.complement(_.matches "^%s*$")), _.split "\n")
2929

@@ -60,7 +60,7 @@ local function check(opts)
6060
report_ok(("%s: `%s`"):format(opts.name, version or "Ok"))
6161
end):on_failure(function(err)
6262
local report = opts.relaxed and report_warn or report_error
63-
report(("%s: not available"):format(opts.name), { tostring(err) })
63+
report(("%s: not available"):format(opts.name), opts.advice or { tostring(err) })
6464
end)
6565
permit:forget()
6666
end
@@ -249,13 +249,20 @@ local function check_languages()
249249
check_thunk { cmd = "java", args = { "-version" }, name = "java", use_stderr = true, relaxed = true },
250250
check_thunk { cmd = "julia", args = { "--version" }, name = "julia", relaxed = true },
251251
function()
252-
if platform.is.win then
253-
check { cmd = "python", args = { "--version" }, name = "python", relaxed = true }
254-
check { cmd = "python", args = { "-m", "pip", "--version" }, name = "pip", relaxed = true }
255-
else
256-
check { cmd = "python3", args = { "--version" }, name = "python3", relaxed = true }
257-
check { cmd = "python3", args = { "-m", "pip", "--version" }, name = "pip3", relaxed = true }
258-
end
252+
local python = platform.is.win and "python" or "python3"
253+
check { cmd = python, args = { "--version" }, name = "python", relaxed = true }
254+
check { cmd = python, args = { "-m", "pip", "--version" }, name = "pip", relaxed = true }
255+
check {
256+
cmd = python,
257+
args = { "-c", "import venv" },
258+
name = "python venv",
259+
relaxed = true,
260+
advice = {
261+
[[On Debian/Ubuntu systems, you need to install the python3-venv package using the following command:
262+
263+
apt-get install python3-venv]],
264+
},
265+
}
259266
end,
260267
function()
261268
a.scheduler()

0 commit comments

Comments
 (0)