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

Set-BuildEnvironment fails when git is not installed #133

Open
rdavisunr opened this issue Jul 15, 2022 · 0 comments
Open

Set-BuildEnvironment fails when git is not installed #133

rdavisunr opened this issue Jul 15, 2022 · 0 comments

Comments

@rdavisunr
Copy link

rdavisunr commented Jul 15, 2022

Hello,

Set-BuildEnvironment fails when git is not installed.

This has been an issue in the past, so there must have been a regression error at some point.

BuildHelpers Version

2.0.16

PowerShell Version

7.2.5 (Core)

Cause Locations

  • Get-BuildVariable.ps1 (line 79)
  • Get-ProjectName.ps1 (line 57)

Error Source

The lines that are failing both fail for the same reason...

if(!$PSboundParameters.ContainsKey('GitPath')) {
   $GitPath = (Get-Command $GitPath -CommandType Application -ErrorAction SilentlyContinue)[0].Path
}

(Get-Command $GitPath -CommandType Application -ErrorAction SilentlyContinue) returns $null because git is not found, then the code goes on to access $null[0].Path, which generates an InvalidOperationException: Cannot index into a null array.

Expected Behavior

No errors should occur when git is missing

Actual Behavior

InvalidOperation: C:\Users\Administrator\Documents\PowerShell\Modules\BuildHelpers\2.0.16\Public\Get-BuildVariable.ps1:79
Line |
  79 |          $GitPath = (Get-Command $GitPath -CommandType Application -Er …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot index into a null array.

InvalidOperation: C:\Users\Administrator\Documents\PowerShell\Modules\BuildHelpers\2.0.16\Public\Get-ProjectName.ps1:57
Line |
  57 |          $GitPath = (Get-Command $GitPath -ErrorAction SilentlyContinu …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot index into a null array.

Steps to Reproduce

On a system without git installed...

Install-Module -Name BuildHelpers -RequiredVersion 2.0.16 -Scope CurrentUser

Import-Module BuildHelpers

Set-BuildEnvironment

Workarounds

Install git

References (similar issue from the past)

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

No branches or pull requests

1 participant