From 294ff40284081d1cc3b70773542eb450f2de18d7 Mon Sep 17 00:00:00 2001 From: vector-jnajjar <135140956+vector-jnajjar@users.noreply.github.com> Date: Thu, 25 Apr 2024 10:47:36 +0200 Subject: [PATCH 1/2] Fix crashing when PATH contains multiple choco installations When for some reason the path environment variable contains two installations of chocolatey this function will return a list, which causes a syntax error down the line. Since running choco.exe on the machine will also choose the first installation in the path, I think limiting the found installations to the first is the desired behavior here. --- chocolatey/plugins/module_utils/Common.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chocolatey/plugins/module_utils/Common.psm1 b/chocolatey/plugins/module_utils/Common.psm1 index ac37663..6d6332f 100644 --- a/chocolatey/plugins/module_utils/Common.psm1 +++ b/chocolatey/plugins/module_utils/Common.psm1 @@ -54,7 +54,7 @@ function Get-ChocolateyCommand { $IgnoreMissing ) - $command = Get-Command -Name choco.exe -CommandType Application -ErrorAction SilentlyContinue + $command = Get-Command -Name choco.exe -CommandType Application -ErrorAction SilentlyContinue -TotalCount 1 if (-not $command) { $installDir = if ($env:ChocolateyInstall) { From abb204732ae5e814f9c709e9675c6b99e0c003da Mon Sep 17 00:00:00 2001 From: "Najjar, Johannes" Date: Thu, 13 Jun 2024 17:21:10 +0200 Subject: [PATCH 2/2] Updated documentation --- chocolatey/plugins/modules/win_chocolatey.py | 1 + 1 file changed, 1 insertion(+) diff --git a/chocolatey/plugins/modules/win_chocolatey.py b/chocolatey/plugins/modules/win_chocolatey.py index 0793367..4561800 100644 --- a/chocolatey/plugins/modules/win_chocolatey.py +++ b/chocolatey/plugins/modules/win_chocolatey.py @@ -21,6 +21,7 @@ description: - Manage packages using Chocolatey. - If Chocolatey is missing from the system, the module will install it. +- If there are multiple installations of choco.exe in env:PATH, it will use the first found one requirements: - chocolatey >= 0.10.5 (will be upgraded if older) options: