Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashing when PATH contains multiple choco installations #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vector-jnajjar
Copy link

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.

Description Of Changes

Restricted the output of Get-Command to the first finding

Motivation and Context

I encountered a crashing win_chocolatey task, when on the target machine the path variable contained multiple choco installations. Limiting the finding to the first in the PATH, the same way it would be resolved in the powershell on the machine, fixes this problem.

Testing

I have tried this out before and after the change, the change fixes this issue

Operating Systems Testing

  • Windows 10
  • Windows 11

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v2 compatibility checked?

Related Issue

Fixes #147

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Win_chocolatey task crashes if PATH contains multiple choco.exe on the target machine
1 participant