MoonshotAI / MoonshotAI/kimi-code

Detect-Target returns "win32-arm64 arm64" instead of `"win32-arm64" on ARM64 Windows

Open Beginner friendly
#2,135 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

What version of Kimi Code is running?

None

Which open platform/subscription were you using?

None

Which model were you using?

None

What platform is your computer?

Windows ARM64

What issue are you seeing?

The Detect-Target function in [file/path] returns a malformed target string of win32-arm64 arm64 on ARM64 Windows machines, instead of the expected win32-arm64.

Root Cause

The switch statement matches architecture strings case-insensitively by default, and PowerShell's switch does not stop after the first match unless a break is explicitly added to each case:

$arch = switch ($rawArch) {
    'X64'     { 'x64' }
    'X86'     { 'x86' }
    'Arm64'   { 'arm64' }
    'ARM64'   { 'arm64' }
    'AMD64'   { 'x64' }
    'IA64'    { 'ia64' }
    default   { Die "unsupported architecture: $rawArch" }
}

On an ARM64 machine, $rawArch is the literal string "ARM64", which matches both the 'Arm64' and 'ARM64' cases (case-insensitive, no break). Both blocks execute, producing the array @('arm64', 'arm64') instead of a single string. When that array is interpolated in "win32-$arch", PowerShell joins the elements with a space (via $OFS), producing win32-arm64 arm64.

Fix

Remove the redundant duplicate case and add break to every case to prevent this class of bug in general:

$arch = switch ($rawArch) {
    'X64'     { 'x64'; break }
    'X86'     { 'x86'; break }
    'ARM64'   { 'arm64'; break }
    'AMD64'   { 'x64'; break }
    'IA64'    { 'ia64'; break }
    default   { Die "unsupported architecture: $rawArch" }
}
Environment
  • OS: Windows on ARM64
  • PowerShell version: [fill in, e.g. 7.4.x or 5.1]
Steps to Reproduce
  1. Run Detect-Target on a Windows ARM64 machine.
  2. Observe the returned value is win32-arm64 arm64 instead of win32-arm64.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the PowerShell file containing the Detect-Target function and inspect its architecture switch. Reproduce the ARM64 case or run the relevant CLI checks, then verify that ARM64 produces exactly win32-arm64 and that other architectures still produce their expected targets.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.