{"record":{"id":"27a32c2ef655a9ad","repo":"gitbutlerapp/gitbutler","slug":"moving-it-to-to-preserve-your-existing-file","errorCode":null,"errorMessage":"Moving it to {} to preserve your existing file","messagePattern":"Moving it to (.+?) to preserve your existing file","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/but-installer/src/install_macos.rs","lineNumber":130,"sourceCode":"    fs::create_dir_all(&bin_dir)?;\n\n    // Check for existing 'but' and detect channel switching\n    let but_symlink = bin_dir.join(\"but\");\n    let but_new = bin_dir.join(\"but.new\");\n\n    if but_symlink.exists() && !but_symlink.is_symlink() {\n        // 'but' exists but is not a symlink\n        let now = std::time::SystemTime::now()\n            .duration_since(std::time::UNIX_EPOCH)\n            .unwrap_or_default()\n            .as_secs();\n        let timestamp = format!(\"{now}\");\n        let but_backup = bin_dir.join(format!(\"but.backup.{timestamp}\"));\n        warn(&format!(\n            \"A 'but' binary already exists at {} (not a symlink)\",\n            but_symlink.display()\n        ));\n        warn(&format!(\n            \"Moving it to {} to preserve your existing file\",\n            but_backup.display()\n        ));\n        fs::rename(&but_symlink, &but_backup)?;\n        info(&format!(\n            \"Your original 'but' has been saved to: {}\",\n            but_backup.display()\n        ));\n    } else if but_symlink.is_symlink() {\n        let existing_target = fs::read_link(&but_symlink)?;\n        let existing_target_str = existing_target.to_string_lossy();\n\n        // Detect channel switching\n        let previous_channel = if existing_target_str.contains(\"Nightly\") {\n            Some(Channel::Nightly)\n        } else if existing_target_str.contains(\"/GitButler.app/\") {\n            Some(Channel::Release)\n        } else {","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-installer/src/install_macos.rs#L112-L148","documentation":"Warning from the GitButler macOS installer's CLI setup step (install_macos.rs). When ~/.local/bin/but exists as a regular file rather than a symlink, the installer renames it to ~/.local/bin/but.backup.<unix-seconds> before creating its own symlink, so your existing binary is never destroyed. The subsequent fs::rename uses '?', so if the rename itself fails the install aborts with an io::Error. After the swap, 'but' points to ~/Applications/GitButler.app/Contents/MacOS/gitbutler-tauri and your old binary lives at the printed backup path.","triggerScenarios":"Running the macOS app installer while ~/.local/bin/but is a real file: a cargo-installed but CLI, a homebrew-placed binary, a manually compiled/copied executable, or a dotfile manager that writes actual binaries into ~/.local/bin. The branch is taken when but_symlink.exists() && !but_symlink.is_symlink() (install_macos.rs:118).","commonSituations":"Developer previously built/installed the but CLI from source; another tool also named 'but' on PATH; leftover binary from an earlier manual install; ~/.local/bin shared across machines via sync.","solutions":["Let the installer finish - your file is preserved at the printed but.backup.<timestamp> path; verify with ls -la ~/.local/bin/but*","If you still need the old binary on PATH, rename the backup: mv ~/.local/bin/but.backup.<timestamp> ~/.local/bin/but-custom","Preempt on future installs: mv ~/.local/bin/but ~/bin/but-custom before running the installer","If the install aborted on the rename, fix ownership/permissions of ~/.local/bin (ls -ld ~/.local/bin; chown -R $(whoami) ~/.local/bin) and re-run"],"exampleFix":"# before\nls -la ~/.local/bin/but\n-rwxr-xr-x  1 me  staff  24563200  but        # real binary, will be moved\n\n# after installer runs (auto-backup)\nbut -> ~/Applications/GitButler.app/Contents/MacOS/gitbutler-tauri\nbut.backup.1755689000                                        # your original, kept\n# keep it on PATH under a new name if needed:\nmv ~/.local/bin/but.backup.1755689000 ~/.local/bin/but-custom","handlingStrategy":"validation","validationCode":"# Before running the GitButler macOS installer:\nif [ -f ~/.local/bin/but ] && [ ! -L ~/.local/bin/but ]; then\n  echo \"regular file at ~/.local/bin/but - will be moved to but.backup.<ts>\"\n  mv ~/.local/bin/but ~/bin/but-custom  # or wherever you want it\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check 'ls -la ~/.local/bin/but' before installs and decide the file's fate yourself instead of relying on the auto-backup","Keep custom binaries out of ~/.local/bin or under distinct names (but-custom) so the installer-managed 'but' slot stays free","If you rely on the auto-backup, record the but.backup.<timestamp> path from the log immediately - nothing else tracks it"],"tags":["macos","installer","symlink","backup","cli","filesystem"],"backgroundTag":"file-already-exists","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}