Closed ralish closed 3 years ago
On further investigation this issue is actually caused by #162. The broken module installations mean the internal Get-AWSToolsModule
never returns any results. However, I'm unsure if fixing #162 would fix all possible cases of this issue. Some additional error handling may make sense to add regardless.
This should be fixed once fix for https://github.com/aws/aws-tools-for-powershell/issues/194 is implemented.
This should be fixed in AWS.Tools.Installer 1.0.2.1
This issue is still present for AWS.Tools.Installer 1.0.2.1
. For instance the folder name for EC2 module is missing the 4th revision (last part). It is 4.1.12 instead of 4.1.12.0
This issue is still present for
AWS.Tools.Installer 1.0.2.1
. For instance the folder name for EC2 module is missing the 4th revision (last part). It is 4.1.12 instead of 4.1.12.0
@ThisIsArnab This behaviour is sometimes seen on Windows PowerShell 5.0 and we cannot control this behaviour. The issue disappears after certain number of retries.
Expected Behavior
Invoking
Install-AWSToolsModule
with the-Cleanup
parameter should always work, even if no clean-up needs to be performed, or noAWS.Tools
modules have been installed (excluding the Installer).Current Behavior
In some circumstances invoking
Install-AWSToolsModule
with the-Cleanup
parameter can result in an unhandled exception:This appears to be due to the internal
Get-AWSToolsModule
function not returning any objects if there are noAWS.Tools
modules installed. The function filters out theAWS.Tools.Installer
module.The absence of any returned objects means the subsequent code operates on a
null
object. While the variable is explicitly typed as aPSModuleInfo
array, as no objects are ever returned from the function it's never initialised. The subsequent code attempts to iterate anull
object and access non-existent properties on the array members.Possible Solution
Either explicitly check that the array variable isn't
null
or ensure it's always initialised.Steps to Reproduce (for bugs)
On a system which does not have any existing
AWS.Tools.*
modules installed:Context
Habitually using the
-Cleanup
parameter inInstall-AWSToolsModule
invocations as well as various script logic in continuous integration scenarios. Manually checking for the presence of any existingAWS.Tools.*
modules (minus the installer itself) should not be required.Your Environment
AWS.Tools.Installer
Get-AWSPowerShellVersion
: 4.0.5.0$PSVersionTable.OS
: Property not present on PowerShell 5.1 (Windows Server 2016)$PSVersionTable.PSEdition
: Desktop