{"record":{"id":"950cfa44af12035e","repo":"rtk-ai/rtk","slug":"pi-extension-at-was-not-changed-remove-or-back-up-the-file","errorCode":null,"errorMessage":"Pi extension at {} was not changed; remove or back up the file manually before retrying.","messagePattern":"Pi extension at (.+?) was not changed; remove or back up the file manually before retrying\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/hooks/init.rs","lineNumber":4448,"sourceCode":"/// Install the Pi extension with an explicit confirmation policy for an\n/// existing non-stock file.\npub fn run_pi_mode_with_patch_mode(\n    global: bool,\n    patch_mode: PatchMode,\n    ctx: InitContext,\n) -> Result<()> {\n    let InitContext { dry_run, .. } = ctx;\n    let plugin_path = pi_plugin_path_for_scope(global)?;\n    let extension_was_present = plugin_path.exists();\n\n    warn_if_extension_shared_on_install(global, &plugin_path, PiCompatibleAgent::Pi)?;\n\n    if !validate_stock_pi_plugin_path(&plugin_path, \"Pi extension\", patch_mode, ctx)? {\n        if dry_run {\n            print_dry_run_footer();\n            return Ok(());\n        }\n        anyhow::bail!(\n            \"Pi extension at {} was not changed; remove or back up the file manually before retrying.\",\n            plugin_path.display()\n        );\n    }\n\n    if let Some(parent) = plugin_path.parent() {\n        ensure_pi_extensions_dir(\n            parent,\n            if global {\n                \"Pi extensions directory\"\n            } else {\n                \"local Pi extensions directory\"\n            },\n            ctx,\n        )?;\n    }\n\n    let installed =","sourceCodeStart":4430,"sourceCodeEnd":4466,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/hooks/init.rs#L4430-L4466","documentation":"Before installing/patching the Pi extension, `validate_stock_pi_plugin_path` checks the existing file at the target path against the removal/patch policy. If validation returns false (policy declined, skipped, or only previewed) and the run is not a dry-run, rtk aborts so it never overwrites a stock or unrecognized extension file it did not validate. The user must remove or back up the file manually before retrying.","triggerScenarios":"Running `rtk init` Pi install/patch mode where the target plugin file exists, `validate_stock_pi_plugin_path` returns false (e.g. file is stock/unrecognized content and patch_mode declined removal), and dry_run is false.","commonSituations":"Non-interactive run without `--auto-patch` when a stock extension already exists; user declined the interactive prompt; leftover stock file from a different tool occupying the path.","solutions":["Rerun with `rtk init --auto-patch` so rtk may remove/replace the existing stock file.","Back up and delete the file manually (`mv <path> <path>.bak`), then rerun `rtk init`.","Preview the intended action first with `rtk init --auto-patch --dry-run`.","If the existing file is not RTK's, choose a different extension path or leave it in place."],"exampleFix":"// before (shell)\nrtk init   # Pi extension not changed\n// after (shell)\nmv ~/.pi/extensions/rtk.ts ~/.pi/extensions/rtk.ts.bak && rtk init --auto-patch","handlingStrategy":"fallback","validationCode":"f=~/.pi/extensions/rtk.ts\nif [ -f \"$f\" ]; then echo \"$f exists — use --auto-patch or remove it before rtk init\"; fi","typeGuard":null,"tryCatchPattern":"rtk init || { mv <path> <path>.bak && rtk init --auto-patch; }","preventionTips":["Include `--auto-patch` whenever existing stock extension files may be present.","Run `--dry-run` before the real run in fresh environments.","Keep agent extension directories free of stale files from other tools."],"tags":["uninstall","approval-required","manual-intervention","init"],"backgroundTag":"conflicting-config-options","analyzedSha":"0924356b4caba4989607227b7c8824d3d8098719","analyzedAt":"2026-09-19T19:25:29.612Z","contentChangedAt":"2026-09-19T19:25:29.612Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}