From 02838e6f4e7efd4a15d6ff1567a3b4406d7f0e81 Mon Sep 17 00:00:00 2001 From: Tushar Singh Date: Tue, 23 May 2023 19:46:55 +0000 Subject: [PATCH] Import Get-FileHash from PowerShell's version specific path pwsh, cmd and powershell interoperability breaks `Get-FileHash` cmdlet which is used in .cipd_impl.ps1. The issue prevents loading of correct PowerShell module due to how $PSModulePath is structured in some cases. With this CL, we always import the compatible module at the beginning of the script. This ensures Get-FileHash is always available to us regardless of the PowerShell version being used. Bug: 1443163 Change-Id: I117e5077239c5371bb392b36b521671095029abf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4506722 Commit-Queue: Robbie Iannucci Reviewed-by: Robbie Iannucci Reviewed-by: Adam Todd Auto-Submit: Tushar Singh --- .cipd_impl.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.cipd_impl.ps1 b/.cipd_impl.ps1 index 3d04d34a0..511ed84d1 100644 --- a/.cipd_impl.ps1 +++ b/.cipd_impl.ps1 @@ -33,6 +33,11 @@ param( $VersionFile ) +# Import PowerShell<=5 Get-Filehash from Microsoft.PowerShell.Utility. +# This prevents loading of incompatible Get-FileHash from PowerShell 6+ $PSModulePath. +# See: crbug.com/1443163. +Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + $DepotToolsPath = Split-Path $MyInvocation.MyCommand.Path -Parent # Put depot_tool's git revision into the user agent string.