{"record":{"id":"91045d857cb70fad","repo":"gitbutlerapp/gitbutler","slug":"cannot-write-to","errorCode":null,"errorMessage":"Cannot write to {} ({})","messagePattern":"Cannot write to (.+?) \\((.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/but-installer/src/shell.rs","lineNumber":301,"sourceCode":"            ));\n\n            if needs_path {\n                ui::println_empty();\n                info(\"To use 'but' in this terminal session, you may need to run:\");\n                ui::println(&format!(\"  source \\\"{}\\\"\", cfg.config_path.display()));\n                ui::println_empty();\n                info(\"Or close and reopen your terminal\");\n            }\n        }\n        Err(e) => {\n            use std::io::ErrorKind;\n            let error_msg = match e.kind() {\n                ErrorKind::PermissionDenied => \"permission denied\".to_string(),\n                ErrorKind::NotFound => \"file not found\".to_string(),\n                _ => format!(\"{e}\"),\n            };\n\n            warn(&format!(\n                \"Cannot write to {} ({})\",\n                cfg.config_path.display(),\n                error_msg\n            ));\n            info(\"Please add the following lines to your shell config file manually:\");\n\n            if needs_path {\n                ui::println(&format!(\"  {path_cmd}\"));\n            }\n            if needs_completions {\n                ui::println(&format!(\"  {completion_cmd}\"));\n            }\n        }\n    }\n\n    Ok(())\n}\n","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-installer/src/shell.rs#L283-L319","documentation":"In setup_shell_config (but-installer/src/shell.rs), when appending the 'but' shell integration lines to a detected shell config file fails (std::io error), the installer warns with the config path and a mapped reason (permission denied / file not found / other) and then prints manual instructions so the user can add the lines themselves. Installation continues; only the automatic config step failed.","triggerScenarios":"setup_shell_config (called by setup_config) attempts to write to the detected config path (e.g. ~/.bashrc, ~/.zshrc) and the write returns Err - typically ErrorKind::PermissionDenied or NotFound.","commonSituations":"Running the installer as a different user than the config owner; read-only home directory or NFS-mounted home; config file missing and directory creation also failing; enterprise-managed machines with immutable dotfiles.","solutions":["Follow the printed manual instructions: copy the shown lines into your shell config file by hand.","Fix permissions on the config file/directory (`chown $USER ~/.zshrc; chmod u+w ~/.zshrc`) and re-run the installer.","Create the missing config file if it does not exist (`touch ~/.zshrc`) and re-run.","Check for immutable/managed dotfiles (`lsattr`, `chattr -i`) and unlock if applicable."],"exampleFix":"# before\n$ ./but-installer   # \"Cannot write to /home/me/.zshrc (permission denied)\"\n# after\n$ ls -l ~/.zshrc    # owned by root?\n$ sudo chown me:me ~/.zshrc && chmod u+w ~/.zshrc\n$ ./but-installer","handlingStrategy":"try-catch","validationCode":"# Pre-check writability before running the installer.\ntest -w ~/.zshrc || echo 'config not writable: fix ownership/permissions first'\n[ -f ~/.zshrc ] || touch ~/.zshrc","typeGuard":null,"tryCatchPattern":"try {\n  fs.appendFileSync(configPath, integrationLines);\n} catch (e) {\n  console.warn(`Cannot write to ${configPath} (${e.code ?? e.message}); add these lines manually:`);\n  console.log(integrationLines);\n}","preventionTips":["Run the installer as the same user who owns the dotfiles.","Keep home directories writable (avoid read-only NFS homes for dev accounts).","Create expected config files (touch ~/.zshrc) before installing on fresh machines.","Unset the immutable bit on managed dotfiles before installers append to them."],"tags":["shell-config","installer","filesystem","permissions"],"backgroundTag":"file-write-permission-denied","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}