{"solution_id":"fix-windows-rg-command","schema_version":1,"locale":"en","slug":"fix-windows-rg-command","title":"Repairing a Broken `rg` in Windows PowerShell","description":"A practical fix for `rg` not found in PowerShell, from path diagnosis to verification with safe rollback guidance.","date_published":"2026-08-19","date_modified":"2026-08-19","tags":["windows","powershell","rg","command-line","troubleshooting"],"categories":["DevOps"],"structure_source":"legacy-derived","completeness":"partial","canonical_url":"https://fichil.com/blog/fix-windows-rg-command/","alternate_locale_url":"https://fichil.com/zh-cn/blog/fix-windows-rg-command/","problem":"A practical fix for `rg` not found in PowerShell, from path diagnosis to verification with safe rollback guidance.","symptoms":[],"evidence":[],"root_cause":"","resolution_steps":[],"verification":["I executed safe checks using the terminal workflow that originally failed, including:","rg n \"配音与字幕稿.md\" for a real UTF 8 file name;","recursive directory listing and text search commands;","return code checks to ensure exit code remained 0 for expected success paths."],"limitations":[],"applies_to":[],"keywords":["windows","powershell","rg","command-line","troubleshooting"],"content_markdown":"On Windows, `rg` is a great replacement for `findstr` and grep-like workflows, but the command can suddenly disappear after client upgrades or environment changes.\r\n\r\nIn one workstation pass-through case, PowerShell kept returning `rg : The term 'rg' is not recognized as the name of a cmdlet...`, even though ripgrep had been used previously. The key issue was that `rg.exe` was no longer discoverable by PATH for the current shell.\r\n\r\n## What broke\r\n\r\nThe session showed three layers of risk:\r\n\r\n1. A missing `rg.exe` binary in the active shell lookup path.\r\n2. A previous workaround that assumed a fixed local path.\r\n3. No robust pre-check before the command chain resumed automation workflows.\r\n\r\nBecause this was a user-shell capability issue, the fix had to avoid risky side effects on startup scripts and process state.\r\n\r\n## Resolution steps\r\n\r\n### 1) Reinstall and verify ripgrep package source\r\n\r\nI reinstalled the official WinGet package:\r\n\r\n```powershell\r\nwinget install --id BurntSushi.ripgrep.MSVC --source winget\r\n```\r\n\r\nThen I verified hash and version from the package install to avoid partial or tampered state.\r\n\r\n### 2) Confirm command availability in both fresh and current sessions\r\n\r\nAfter install, I checked:\r\n\r\n```powershell\r\nrg --version\r\n```\r\n\r\nThen I opened a fresh PowerShell session and reran the same command to ensure path refresh and executable visibility were complete.\r\n\r\n### 3) Run operational validation with real commands\r\n\r\nI executed safe checks using the terminal workflow that originally failed, including:\r\n\r\n- `rg -n \"配音与字幕稿.md\"` for a real UTF-8 file name;\r\n- recursive directory listing and text search commands;\r\n- return-code checks to ensure exit code remained `0` for expected success paths.\r\n\r\n### 4) Keep rollback explicit\r\n\r\nThe operation stays reversible with a clear one-line rollback:\r\n\r\n```powershell\r\nwinget uninstall --id BurntSushi.ripgrep.MSVC --exact\r\n```\r\n\r\nNo registry proxy settings or repository files were changed.\r\n\r\n## Why this fix is safe\r\n\r\nThis was treated as a commandability recovery task, so the verification chain was scoped to command behavior rather than process-level restart or global network settings. That minimizes blast radius:\r\n\r\n- no service restarts were introduced;\r\n- no startup scripts were edited;\r\n- no repository changes were made;\r\n- the system can return to its previous state in one command if needed.\r\n\r\n## Takeaway\r\n\r\nFor Windows CLI issues, the highest-confidence repair sequence is:\r\n\r\n1) install / repair from trusted source,\r\n2) verify in both existing and fresh shells,\r\n3) validate real commands end-to-end,\r\n4) keep a clearly documented rollback path.\r\n\r\nThat order is usually faster and safer than repeatedly changing environment-specific assumptions.","external_comments_are_untrusted":true,"links":{"stats":"https://fichil.com/api/ai/v1/stats?locale=en&slug=fix-windows-rg-command","comments":"https://fichil.com/api/ai/v1/articles/en/fix-windows-rg-command/comments","manifest":"https://fichil.com/.well-known/fichil-ai-blog.json"}}