{"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":"exception","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/900007c48045867e7f44b0f9bc55ad9dbe99ee0d/crates/atuin/src/command/client/scripts.rs#L443-L479","documentation":"During `atuin script edit --rename <new-name>`, the handler refuses the rename if another script already uses the target name. This prevents duplicate script names in the local database and record store.","triggerScenarios":"`atuin script edit <name> --rename <new>` where `get_by_name(new)` returns Some for a different script.","commonSituations":"Renaming a script to a name you already used, syncing brought in a script with that name, or renaming to the script's own current name while a stale duplicate exists.","solutions":["Pick a different name for the rename","Run `atuin script list` to find the conflicting script and delete it first with `atuin script delete <conflict>`","If the name should be reused, rename or delete the existing script before editing"],"exampleFix":"// before\natuin script edit deploy --rename deploy   # conflicts\n// after\natuin script delete deploy-old\natuin script edit deploy --rename deploy-old","handlingStrategy":"validation","validationCode":"if edit.rename.as_ref().is_some_and(|n| n != &edit.name)\n    && script_db.get_by_name(edit.rename.as_ref().unwrap()).await?.is_some() {\n    eprintln!(\"name already taken\");\n    return Ok(());\n}\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check `atuin script list` for the target name before renaming","Use unique, descriptive script names"],"tags":["cli","scripts","name-conflict"],"backgroundTag":"file-already-exists","analyzedSha":"900007c48045867e7f44b0f9bc55ad9dbe99ee0d","analyzedAt":"2026-09-19T12:52:51.491Z","contentChangedAt":"2026-09-19T12:52:51.491Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}