Skip to content

Does not properly detect cross-platform PowerShell (pwsh) #6408

Description

@heaths

Please complete the following tasks

Rust Version

rustc 1.98.0-nightly (beae78130 2026-06-09)

Clap Version

4.6.1

Minimal reproducible code

fn main() {
    clap_complete::CompleteEnv::with_factory(Args::command).complete();
}

#[derive(clap::Parser)]
#[command]
struct Args;

Steps to reproduce the bug with the above code

  1. Install pwsh e.g., brew install powershell on macOS or linux.
  2. Run: pwsh
  3. cargo add clap clap-complete -F clap/derivbe,clap-complete/unstable-dynamic
  4. Run: COMPLETE=$(which pwsh) cargo run. This is documented as supported in source. The main idea anyway is to show that, on any platform including Windows (powershell.exe is supported but basically EOL; pwsh is the way forward and has been for many years), pwsh is the executable you should be checking.

Actual Behaviour

error: unknown shell pwsh, expected one of bash, elvish, fish, powershell, zsh

Expected Behaviour

Works like it would if the executable were powershell or for any other shell like bash.

Additional Context

Based on PowerShell/PowerShell#12150 and my own testing, SHELL is unreliable. Seems only the initial shell sets it. Once set, it's never overwritten, which is partly why PowerShell closed it. Even if I start bash (default shell) then zsh on macOS, SHELL is still "bash".

Some other programs detect the parent process tree up to ~10 processes or so using sysinfo or similar.

Debug Output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-completionArea: completion generatorC-bugCategory: bugE-easyCall for participation: Experience needed to fix: Easy / not much

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions