Skip to content

"Feature Request: Allow configuring the default shell execution environment (e.g., pwsh, bash, nu) instead of hardcoded powershell.exe on Windows." #15493

Description

@Shallow-dusty

What would you like to be added?

On Windows, the CLI currently defaults to powershell.exe (v5.1) for run_shell_command. This creates a bottleneck
because:

  1. Encoding Issues: Native PowerShell defaults to GBK (936), causing encoding mismatches/mojibake when modern tools
    (like eza, lsd, or git) output UTF-8.
  2. Limited Modern Features: Many users have migrated to pwsh (v7+) or NuShell for better performance and
    cross-platform compatibility.
  3. Environment Isolation: Users often have their dev environment set up in pwsh, but the CLI executes commands in a
    different, unconfigured environment.
    Desired outcome: Add a setting (e.g., tools.shell.executablePath) to allow users to specify their preferred shell
    executable.

Why is this needed?

Unlocks Modern Windows Tooling & Fixes Encoding by Design

  1. UTF-8 First: The legacy powershell.exe defaults to legacy encodings (GBK/CP936), causing mojibake with almost
    all modern CLI tools (Rust-based tools like eza, ripgrep, or even Node/Python scripts). Configuring the shell to pwsh
    (which handles UTF-8 correctly by default) fixes this natively without hacky $PROFILE modifications.
  2. User Preference & Consistency: Developers invest time configuring their shell (pwsh, nu, bash) with specific
    aliases, environment variables, and tools. Forcing execution in a raw powershell.exe environment breaks this
    consistency and limits the CLI's potential integration with the user's workflow.

Additional context

📋 原始测试日志 (Raw Test Logs)

TEST 1: PowerShell 7 (pwsh) [Profile Enabled] <<<
Active code page: 65001
.
鈹溾攢鈹€ 鍙傝€冭祫鏂
鈹溾攢鈹€ 瀹炰範鏂囨。
鈹溾攢鈹€ 宸ョ▼鏂囦欢
鈹斺攢鈹€ 杞欢宸ュ叿

TEST 2: Windows PowerShell (powershell) [Profile Enabled] <<<
Active code page: 65001
.
鈹溾攢鈹€ 鍙傝€冭祫鏂
鈹溾攢鈹€ 瀹炰範鏂囨。
鈹溾攢鈹€ 宸ョ▼鏂囦欢
鈹斺攢鈹€ 杞欢宸ュ叿

TEST 3: NuShell (nu) <<<
.
鈹溾攢鈹€ 鍙傝€冭祫鏂
鈹溾攢鈹€ 瀹炰範鏂囨。
鈹溾攢鈹€ 宸ョ▼鏂囦欢
鈹斺攢鈹€ 杞欢宸ュ叿

TEST 4: CMD (cmd) <<<
Active code page: 65001
.
鈹溾攢鈹€ 鍙傝€冭祫鏂
鈹溾攢鈹€ 瀹炰範鏂囨。
鈹溾攢鈹€ 宸ョ▼鏂囦欢
鈹斺攢鈹€ 杞欢宸ュ叿


Technical Observations:

  1. Brittle Encoding Management: As shown in the logs, even after manually forcing the code page to 65001 (UTF-8) via
    $PROFILE modifications, modern tools like eza still produce mojibake (broken characters) when piped through the
    hardcoded powershell.exe session used by the CLI agent. This demonstrates that simply "patching" the legacy shell is
    not a robust solution.

  2. Shell Inconsistency: While NuShell (Test 3) handles these characters natively and correctly, it must be manually
    invoked as a sub-process of powershell.exe, leading to unnecessary overhead and potential environment variable loss.

  3. The Hidden Bottleneck: The native powershell.exe (v5.1) is an outdated execution host for AI agents. By
    hardcoding it, the CLI prevents users from leveraging the native UTF-8 handling and modern features of pwsh or nu,
    which are standard in modern Windows development workflows.

Conclusion: Allowing a configurable shell path would allow the CLI to use a modern shell host directly, eliminating
these encoding artifacts and aligning with the user's actual development environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/coreIssues related to User Interface, OS Support, Core Functionalitypriority/p2Important but can be addressed in a future release.🔒 maintainer only⛔ Do not contribute. Internal roadmap item.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions