{"record":{"id":"bdd03fec0f9986c5","repo":"atuinsh/atuin","slug":"a-script-named-already-exists","errorCode":null,"errorMessage":"A script named '{}' already exists","messagePattern":"A script named '(.+?)' already exists","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/atuin/src/command/client/scripts.rs","lineNumber":461,"sourceCode":"        script_store: ScriptStore,\n        script_db: atuin_scripts::database::Database,\n    ) -> Result<()> {\n        debug!(\"editing script {:?}\", edit);\n        // Find the existing script\n        let existing_script = script_db.get_by_name(&edit.name).await?;\n        debug!(\"existing script {:?}\", existing_script);\n\n        if let Some(mut script) = existing_script {\n            // Update the script with new values if provided\n            if let Some(description) = edit.description {\n                script.description = description;\n            }\n\n            // Handle renaming if requested\n            if let Some(new_name) = edit.rename {\n                // Check if a script with the new name already exists\n                if (script_db.get_by_name(&new_name).await?).is_some() {\n                    bail!(\"A script named '{}' already exists\", new_name);\n                }\n\n                // Update the name\n                script.name = new_name;\n            }\n\n            // Handle tag updates with priority:\n            // 1. If --no-tags is provided, clear all tags\n            // 2. If --tags is provided, replace all tags\n            // 3. If neither is provided, tags remain unchanged\n            if edit.no_tags {\n                // Clear all tags\n                script.tags.clear();\n            } else if !edit.tags.is_empty() {\n                // Replace all tags\n                script.tags = edit.tags;\n            }\n            // If none of the above conditions are met, tags remain unchanged","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/atuinsh/atuin/blob/c0c717ab04c881764bcad4b3d169a507e2432643/crates/atuin/src/command/client/scripts.rs#L443-L479","documentation":"When renaming a script via `atuin scripts edit --rename <new-name>`, atuin first checks the script database for an existing script with the new name and refuses the rename to avoid collisions. The error surfaces before any rename or record rebuild happens.","triggerScenarios":"Running `atuin scripts edit OLD --rename NEW` where `script_db.get_by_name(NEW)` already returns a script.","commonSituations":"Trying to rename to a name that already exists (perhaps on another machine, then synced), or accidentally reusing an old script's name.","solutions":["Choose a different, unique new name.","Run `atuin scripts list` to confirm which names are taken.","Delete the conflicting script first (`atuin scripts delete NEW`) if it's no longer wanted, then retry the rename."],"exampleFix":"// before\natuin scripts edit deploy --rename deploy\n// after\natuin scripts edit deploy --rename deploy-v2","handlingStrategy":"validation","validationCode":"# shell\natuin scripts list | grep -qx \"$new_name\" && { echo \"name '$new_name' already taken\" >&2; exit 1; }\natuin scripts edit \"$old\" --rename \"$new_name\"","typeGuard":null,"tryCatchPattern":"if ! atuin scripts edit \"$old\" --rename \"$new\" 2>&1; then\n  echo \"pick a unique name; current names:\"; atuin scripts list\nfi","preventionTips":["Check `atuin scripts list` before renaming.","Adopt a naming convention (prefixes) that reduces collisions.","Sync first so names taken on other machines are visible locally."],"tags":["cli","name-conflict","scripts"],"backgroundTag":"file-already-exists","analyzedSha":"c0c717ab04c881764bcad4b3d169a507e2432643","analyzedAt":"2026-09-12T07:40:01.341Z","contentChangedAt":"2026-09-12T07:40:01.341Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}