{"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":"info","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/58e5313667b857ef39a730e380af31816a7b1768/crates/but-installer/src/install_macos.rs#L112-L148","documentation":"Second warning in the same flow: the installer tells the user exactly where the displaced 'but' binary is being moved (but.backup.<unix-timestamp>) so their original file is preserved before the symlink replaces it. Immediately after, fs::rename performs the move.","triggerScenarios":"Raised in install_app (download_and_install_app) right after detecting the non-symlink 'but' binary, immediately before fs::rename(&but_symlink, &but_backup); always paired with the preceding 'already exists' warning.","commonSituations":"Same collision scenario as the preceding warning: upgrades from copy-based installs, local builds, or package-manager-owned binaries in the target bin dir.","solutions":["Note the printed backup path; your original binary is intact there and can be restored with mv if needed.","If the rename itself fails (logged error), move the file manually: mv <bin_dir>/but <bin_dir>/but.backup.manual and re-run the installer.","Remove the stale binary if it is no longer wanted, then re-run the installer for a clean symlink.","Check timestamps if multiple but.backup.* files accumulate and delete old ones you don't need."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# Note and verify backup location after install\nimport glob, os\nprint(glob.glob(os.path.expanduser('<bin_dir>/but.backup.*')))","typeGuard":null,"tryCatchPattern":"// Ensure the rename away of the old binary reports failures clearly\nfs::rename(&but_symlink, &but_backup)\n    .map_err(|e| anyhow!(\"could not preserve existing but binary: {e}\"))?;","preventionTips":["Record the printed backup path before confirming the install","Clean up old but.backup.* files periodically, keeping the most recent one","Restore with mv if the new symlinked version misbehaves"],"tags":["macos","installer","backup","symlink"],"backgroundTag":"file-already-exists","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"}