#3691·rtk

Windows PowerShell cmdlets and quoted cmd.exe commands are not handled transparently by rtk

Author: Mrugen007Created Aug 24, 2026Updated Sep 16, 2026
Labelsenhancementarea:clipriority:mediumplatform:windows

Summary When rtk is used from PowerShell, commands fall into two categories:

PowerShell cmdlets, such as Get-ChildItem and Get-Command. Native executables, such as where.exe, cmd.exe, and powershell.exe. Native executables are forwarded correctly by rtk. PowerShell cmdlets are treated as external binaries and fail because they do not exist on PATH.

Reproduction Run the following command in PowerShell:

rtk Get-ChildItem

Actual result:

rtk: Failed to resolve 'Get-ChildItem' via PATH, falling back to direct exec: Binary 'Get-ChildItem' not found on PATH [rtk: program not found] Command exited with code 1

The equivalent PowerShell command works:

Get-ChildItem

The same issue occurs with PowerShell pipelines:

rtk Get-ChildItem -LiteralPath "C:\some\path" | Select-Object Name,Length,LastWriteTime

rtk Get-Command pandoc,wkhtmltopdf,chrome,msedge -ErrorAction SilentlyContinue | Select-Object Name,Source

Verified Behavior The following command works when PowerShell is invoked explicitly through rtk:

rtk powershell.exe -NoProfile -Command "Get-ChildItem -LiteralPath 'C:\some\path' -Filter 'AISense-NumPy-Cv2-Resolution-Guide-v2*' | Select-Object Name,Length,LastWriteTime"

A native executable also works through rtk:

rtk where.exe rtk

This confirms that the issue is specific to direct PowerShell cmdlet invocation, not all Windows command execution.

Separate Environment Findings The following command failed because rg is not installed or available on PATH:

rtk rg --files "C:\some\path"

The direct command also fails:

rg --files "C:\some\path"

The following commands returned no matches because the requested tools were not installed:

rtk where.exe pandoc rtk where.exe wkhtmltopdf rtk where.exe chrome rtk where.exe msedge rtk where.exe soffice

These results are environment-related and should be tracked separately from the PowerShell cmdlet handling issue.

Quoting Consideration Commands involving cmd.exe /c can produce a separate failure when Unix-style escaping is used in PowerShell:

rtk cmd.exe /c "if exist "C:\Program Files...\tool.exe" ..."

PowerShell does not use a backslash to escape double quotes. A safer form is:

rtk cmd.exe /c 'if exist "C:\Program Files...\tool.exe" (echo FOUND) else (echo MISSING)'

Failures involving cmd.exe /c should therefore be evaluated separately from the direct PowerShell cmdlet issue.

Expected Behavior rtk should either:

Detect PowerShell cmdlets and execute them through PowerShell while preserving pipelines, arguments, and exit codes; or Clearly document that direct PowerShell cmdlet invocation is unsupported and recommend: rtk powershell.exe -NoProfile -Command "..."

The documentation should also explain the correct quoting rules when invoking cmd.exe /c from PowerShell.

Impact Users working in PowerShell may reasonably expect commands such as the following to work:

rtk Get-ChildItem rtk Get-Command rtk Test-Path rtk Where-Object

Instead, these commands fail with a misleading "program not found" error. This can make valid PowerShell commands appear to be unavailable or broken when the actual limitation is that rtk resolves commands through PATH rather than through the PowerShell command system.

Recommended Workaround Run PowerShell cmdlets directly:

Get-ChildItem ... | Select-Object ... Get-Command ... | Select-Object ...

Use rtk for native executables and supported rtk subcommands. When rtk output filtering is required for a PowerShell command, invoke powershell.exe explicitly:

rtk powershell.exe -NoProfile -Command "..."