Skip to content

feat(windows): native Windows support without WSL - #2355

Closed
dave92082 wants to merge 2 commits into
rtk-ai:developfrom
dave92082:feature/full-windows-native-support
Closed

dave92082 wants to merge 2 commits into
rtk-ai:developfrom
dave92082:feature/full-windows-native-support

Conversation

@dave92082

Copy link
Copy Markdown

This pull request significantly improves RTK's native Windows support, especially around UNIX-style command filters, and enhances cross-platform behavior and documentation. The most important changes include updating documentation to clarify full Windows support (no WSL required), introducing detection and user guidance for missing Coreutils tools on Windows, and refactoring platform-specific paths and logic for better portability and testability. Several tests and code paths were updated to ensure robust cross-platform operation.

Windows Support and Documentation:

  • Updated README.md to clarify that RTK is fully supported on native Windows (no WSL required), and added guidance to install Microsoft Coreutils for full filter functionality. The documentation now includes improved setup instructions and a feature comparison table across Windows, WSL, and Linux/macOS. [1] [2]

Coreutils Tool Detection and User Guidance:

  • Added a COREUTILS_TOOLS constant and a missing_coreutils function in src/core/utils.rs to detect missing UNIX-style tools (like ls, grep, etc.) on PATH. On Windows, commands now print a one-line hint to install Microsoft Coreutils if any tools are missing. [1] [2] [3] [4] [5]

Cross-Platform Path Handling and Environment Logic:

  • Refactored all uses of hardcoded Unix paths to use platform-aware APIs (dirs::data_local_dir, std::env::temp_dir) for log and telemetry file locations, ensuring correct behavior on Windows and other platforms. [1] [2] [3] [4]
  • Updated PATH variable splitting in env_cmd.rs to use env::split_paths for platform-aware handling, and added corresponding unit tests. [1] [2]

Testing Improvements:

  • Added or updated tests to ensure platform-specific logic is correct, including tests for path splitting, coreutils detection, and log path resolution. Some streaming and exec tests are now gated to run only on non-Windows platforms where appropriate. [1] [2] [3] [4] [5] [6] [7]

These changes collectively make RTK's Windows experience first-class, improve user onboarding, and ensure robust cross-platform operation.

RTK now runs fully on native Windows. Investigation showed it was already
~85% there (which/PATHEXT binary resolution, cmd /C shell branch, dirs-based
paths, the cross-platform `rtk hook claude` binary). This closes the gaps.

- env: split PATH with std::env::split_paths (`;` on Windows) instead of `:`
- hook-audit: resolve log path via dirs::data_local_dir() instead of
  hardcoded $HOME/.local/share + /tmp fallback
- telemetry: fall back to std::env::temp_dir() instead of "/tmp"
- coreutils: detect Microsoft Coreutils (ls/grep/wc/...) in `rtk verify` and
  `rtk init -g`, guiding users to `winget install Microsoft.Coreutils`
- tests: gate 5 sh-dependent stream tests with cfg(not(windows)) so
  `cargo test --all` is green on native Windows; add cross-platform unit
  tests for the PATH split, audit path, and coreutils detection
- docs: rewrite README Windows section — native is fully supported
  (auto-rewrite included); WSL is now optional, not required
@CLAassistant

CLAassistant commented Jun 9, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@IwakuraRein

Copy link
Copy Markdown

Looks like rtk still doesn't catch native powershell cmd? For example:

rtk ls                       # works
rtk Get-ChildItem            # rtk: Failed to resolve 'Get-ChildItem' via PATH, falling back to direct exec: 
                             # Binary 'Get-ChildItem' not found on PATH
                             # [rtk: program not found]
rtk powershell Get-ChildItem # the same output

PowerShell cmdlets (Get-ChildItem, Get-Content, ...), functions, aliases,
and cmd.exe builtins (dir, echo) are not standalone executables on PATH —
they only exist inside a shell. RTK resolved every command via `which` and
spawned it directly with no shell, so these failed with "program not found"
(exit 127); `rtk ls` only worked because Coreutils ships a real ls.exe.

Add `passthrough_command`: on Windows, when a command does not resolve to a
PATH binary, run it through PowerShell (prefers pwsh, falls back to
powershell) with -NoProfile instead of failing. Behavior on other platforms
is unchanged. Wire it into the three run_fallback passthrough sites.

Addresses PR rtk-ai#2355 review feedback that `rtk Get-ChildItem` failed.

Verified on Windows 11: clippy --all-targets clean, cargo test --all 2145
passed (incl. 4 new tests); rtk Get-ChildItem / powershell Get-ChildItem /
dir all run correctly, rtk --version unaffected.

Generated with AI

Co-Authored-By: AI <ai@example.com>
@dave92082

Copy link
Copy Markdown
Author

@IwakuraRein The issues with powershell should be addressed

@rtk-release-bot

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet.

@rtk-release-bot

Copy link
Copy Markdown
Contributor

Closing this pull request after a prolonged period of inactivity. If this is still relevant, please ask for it to be reopened. Thank you!

@rtk-release-bot rtk-release-bot Bot closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants