Kiro icon indicating copy to clipboard operation
Kiro copied to clipboard

Total catastrophic failure of powershell terminal to do literally anything + fix

Open Doc-Neil opened this issue 1 year ago • 1 comments

Before opening, please confirm:

Operating System

Windows 11 Pro 64 bit

Kiro Version

0.5.35

Bug Description

Kiro Bug Report: Corrupted shellIntegration.ps1 Causes Terminal Failure

Summary

Kiro ships with a corrupted shellIntegration.ps1 file that causes all terminal operations to fail with ERROR_INVALID_IMAGE_HASH (-2147023895). The corrupted script crashes PowerShell on execution, preventing any terminal functionality in Kiro.

Environment

  • OS: Windows 10/11
  • Kiro Version: Latest (as of November 15, 2025)
  • Installation Type: Fresh install
  • PowerShell Version: 5.1.26100.7019

Steps to Reproduce

  1. Install Kiro fresh on Windows
  2. Attempt to open integrated terminal (Ctrl+` or Terminal menu)
  3. Observe error popup: "The terminal process terminated with exit code: -2147023895"
  4. All executePwsh commands fail with "Signal was cancelled"

Expected Behavior

  • Terminal should open successfully
  • PowerShell should start with shell integration enabled
  • Commands should execute normally

Actual Behavior

  • Terminal fails to open
  • Error popup appears: "The terminal process terminated with exit code: -2147023895"
  • Windows Event Viewer shows PowerShell startup logs but immediate termination
  • All process spawning in Kiro fails

Root Cause

The file shellIntegration.ps1 located at:

C:\Users\[User]\AppData\Local\Programs\Kiro\resources\app\out\vs\workbench\contrib\terminal\common\scripts\shellIntegration.ps1

Is corrupted or malformed. When PowerShell attempts to execute this script (via -command try { . "shellIntegration.ps1" } catch {}), it:

  1. First execution: Produces no output
  2. Second execution: Crashes PowerShell entirely
  3. Causes Windows to return ERROR_INVALID_IMAGE_HASH

Technical Details

Error Code

  • Exit Code: -2147023895
  • Hex: 0x800703E9
  • Windows Error: ERROR_INVALID_IMAGE_HASH
  • Meaning: "The hash for the image cannot be found in the system catalogs. The image is likely corrupt or the victim of tampering."

Script Status

Get-AuthenticodeSignature "...\shellIntegration.ps1"
Status: NotSigned

The script is unsigned (expected) but also corrupted/malformed.

PowerShell Event Logs

Event Viewer shows PowerShell starting with the command:

powershell.exe -noexit -command try { . "c:\Users\User\AppData\Local\Programs\Kiro\resources\app\out\vs\workbench\contrib\terminal\common\scripts\shellIntegration.ps1" } catch {}

But immediately terminates with ERROR_INVALID_IMAGE_HASH.

Workaround

Replace the corrupted file with a clean version from VS Code repository:

  1. Rename broken file:
Rename-Item "C:\Users\[User]\AppData\Local\Programs\Kiro\resources\app\out\vs\workbench\contrib\terminal\common\scripts\shellIntegration.ps1" "shellIntegration.ps1.broken"
  1. Download clean version from:
https://github.com/microsoft/vscode/raw/main/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.ps1
  1. Place in same directory
  2. Restart Kiro

Terminal functionality is restored immediately.

Impact

  • Severity: Critical
  • Affected Users: All Windows users with fresh Kiro installations
  • Workaround Available: Yes (manual file replacement)

Questions for Kiro Team

  1. How is this file corrupted in the distribution?

    • Build process issue?
    • Packaging problem?
    • Code signing issue?
  2. Why doesn't Kiro validate this file on startup?

    • Could add integrity check for critical shell integration scripts
    • Could provide better error messages when script fails
  3. Why does the error message not indicate the actual problem?

    • "Signal was cancelled" is misleading
    • Should show "Shell integration script failed" or similar
    • Should log the actual PowerShell error
  4. Is this affecting other platforms?

    • Does the bash/zsh equivalent have similar issues?

Suggested Fixes

Immediate

  1. Fix the build/packaging process that's corrupting shellIntegration.ps1
  2. Add file integrity validation on Kiro startup
  3. Provide fallback behavior if shell integration fails (open terminal without integration)

Long-term

  1. Improve error messages for terminal failures
  2. Add diagnostic tool to check shell integration health
  3. Provide in-app repair option for corrupted files
  4. Better logging of terminal startup failures

Additional Notes

What Didn't Work (Red Herrings)

  • Running as Administrator
  • Reinstalling Kiro
  • Running SFC /scannow
  • Running DISM
  • Updating NVIDIA drivers (initially suspected due to unrelated service crashes)
  • Disabling Code Integrity policies
  • Changing PowerShell execution policy (already Bypass)
  • Checking AppLocker policies
  • Checking Windows Defender Application Control

What Actually Worked

  • Replacing the corrupted shellIntegration.ps1 file with a clean version

Reproduction Rate

100% on affected installations. The corrupted file is consistently present in fresh Kiro installations.

Files to Investigate

  • Build scripts that package shellIntegration.ps1
  • Code signing process for Kiro distribution
  • File integrity checks during installation
  • Error handling in terminal initialization code

Submitted by: User experiencing critical terminal failure Date: November 15, 2025 Time to Resolution: ~3 hours of troubleshooting Workaround Effectiveness: 100% - immediate fix upon file replacement

Steps to Reproduce

Download latest Kiro for Windows Install Try to open terminal

Expected Behavior

It should, yknow, open the terminal and let you do stuff using it.

Conversation ID

386d4d27-9f16-43e9-892d-d3bf1a7fbb2f

Additional Context

No response

Doc-Neil avatar Nov 15 '25 01:11 Doc-Neil

Seems like this is solvable by updating PowerShell to the latest version. I found 7.5.4.0 to restore all shell function in Kiro.

https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell-on-windows?view=powershell-7.5

Doc-Neil avatar Dec 30 '25 21:12 Doc-Neil