diff --git a/packages/safe-chain/src/shell-integration/helpers.js b/packages/safe-chain/src/shell-integration/helpers.js index 8f1450d..36fa908 100644 --- a/packages/safe-chain/src/shell-integration/helpers.js +++ b/packages/safe-chain/src/shell-integration/helpers.js @@ -259,8 +259,9 @@ export async function validatePowerShellExecutionPolicy(shellExecutableName) { try { // For Windows PowerShell (5.1), clean PSModulePath to avoid conflicts with PowerShell 7 modules - // When PowerShell 7 is installed, it adds its module paths to PSModulePath, causing - // Windows PowerShell to try loading incompatible PowerShell 7 modules (TypeData conflicts) + // When safe-chain is invoked from PowerShell 7, it sets its module paths to PSModulePath, causing + // Windows PowerShell to try loading incompatible PowerShell 7 modules. + // Setting the environment to Windows PowerShell's modules fixes this. let spawnOptions; if (shellExecutableName === "powershell") { const userProfile = process.env.USERPROFILE || ""; @@ -283,7 +284,7 @@ export async function validatePowerShellExecutionPolicy(shellExecutableName) { const commandResult = await safeSpawn( shellExecutableName, ["-Command", "Get-ExecutionPolicy"], - spawnOptions + spawnOptions, ); const policy = commandResult.stdout.trim(); diff --git a/packages/safe-chain/src/shell-integration/supported-shells/powershell.js b/packages/safe-chain/src/shell-integration/supported-shells/powershell.js index b05b57b..657548a 100644 --- a/packages/safe-chain/src/shell-integration/supported-shells/powershell.js +++ b/packages/safe-chain/src/shell-integration/supported-shells/powershell.js @@ -40,7 +40,6 @@ function teardown(tools) { } async function setup() { - // Check execution policy const { isValid, policy } = await validatePowerShellExecutionPolicy(executableName); if (!isValid) { diff --git a/packages/safe-chain/src/shell-integration/supported-shells/windowsPowershell.js b/packages/safe-chain/src/shell-integration/supported-shells/windowsPowershell.js index 17820e0..f6f67aa 100644 --- a/packages/safe-chain/src/shell-integration/supported-shells/windowsPowershell.js +++ b/packages/safe-chain/src/shell-integration/supported-shells/windowsPowershell.js @@ -40,7 +40,6 @@ function teardown(tools) { } async function setup() { - // Check execution policy const { isValid, policy } = await validatePowerShellExecutionPolicy(executableName); if (!isValid) {