{"record":{"id":"f5ada17d50872e69","repo":"astrid-runtime/astrid","slug":"install-dir-is-not-writable-re-run-with-elevat","errorCode":null,"errorMessage":"{install_dir} is not writable — re-run with elevated permissions, or reinstall via Homebrew/cargo.","messagePattern":"(.+?) is not writable — re-run with elevated permissions, or reinstall via Homebrew/cargo\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/self_update/mod.rs","lineNumber":618,"sourceCode":"        },\n        UpdatePlan::DeferToManager { manager, how } => {\n            println!(\n                \"{}\",\n                Theme::info(&format!(\n                    \"Astrid was installed via {manager}. Update it with:\\n  {how}\"\n                ))\n            );\n            return Ok(());\n        },\n        UpdatePlan::ApplyInPlace => {},\n    }\n\n    let install_dir = exe\n        .parent()\n        .ok_or_else(|| anyhow::anyhow!(\"cannot resolve install directory for {}\", exe.display()))?\n        .to_path_buf();\n    if !is_writable_dir(&install_dir) {\n        bail!(\n            \"{} is not writable — re-run with elevated permissions, or reinstall via Homebrew/cargo.\",\n            install_dir.display()\n        );\n    }\n\n    if !confirm(\n        &format!(\n            \"Update Astrid v{CURRENT_VERSION} → v{version_str} in {}?\",\n            install_dir.display()\n        ),\n        args.yes,\n    )? {\n        println!(\"{}\", Theme::dimmed(\"Update cancelled.\"));\n        return Ok(());\n    }\n\n    let (_tmp_dir, extract_dir) = download_verify_extract(\n        &client,","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/self_update/mod.rs#L600-L636","documentation":"run_self_update resolves the directory containing the current executable and checks writability (is_writable_dir) before downloading and swapping in a new build. If the install directory is not writable by the current user, the update is refused with instructions to either elevate or reinstall through a package manager. This prevents a partially applied update that would leave a broken binary behind.","triggerScenarios":"Executing `astrid self update` while the executable lives in a directory the user cannot write to, e.g. /usr/local/bin or C:\\Program Files, without elevated privileges.","commonSituations":"Astrid was installed system-wide with sudo but is updated as a normal user; corporate-managed machines with read-only Program Files; Homebrew/cargo-managed installs where the user shouldn't self-update at all.","solutions":["Re-run the update with elevated permissions: `sudo -E astrid self update` (or an elevated shell on Windows).","Prefer reinstalling/upgrading via Homebrew or cargo when the install is package-manager-managed.","Move the installation to a user-writable location (e.g. ~/.local/bin) and ensure PATH points there, then self-update normally."],"exampleFix":"// before\n$ astrid self update\nerror: /usr/local/bin is not writable — re-run with elevated permissions...\n\n// after\n$ sudo astrid self update\n# or\n$ brew upgrade astrid","handlingStrategy":"validation","validationCode":"let dir = std::env::current_exe()?.parent().unwrap().to_path_buf();\nlet probe = dir.join(\".astrid-write-test\");\nif std::fs::write(&probe, b\"\").is_err() {\n    eprintln!(\"{} is not writable; use sudo or a package manager\", dir.display());\n} else {\n    let _ = std::fs::remove_file(&probe);\n}","typeGuard":null,"tryCatchPattern":"match run_self_update().await {\n    Err(e) if e.to_string().contains(\"is not writable\") => {\n        eprintln!(\"Re-run with sudo or upgrade via brew/cargo.\");\n    }\n    other => other?,\n}","preventionTips":["Install Astrid under a user-writable prefix such as ~/.local/bin.","For system-wide installs, always update with elevated privileges or via brew/cargo.","Check writability of the exe's directory before scheduling automated updates."],"tags":["self-update","permissions","filesystem","install-directory"],"backgroundTag":"file-write-permission-denied","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}