atuinsh/atuin · error

A script named ' ' already exists

Error message

A script named '{}' already exists

What it means

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.

Solutions

  1. Pick a different name for the rename
  2. Run `atuin script list` to find the conflicting script and delete it first with `atuin script delete <conflict>`
  3. If the name should be reused, rename or delete the existing script before editing

Example fix

// before
atuin script edit deploy --rename deploy   # conflicts
// after
atuin script delete deploy-old
atuin script edit deploy --rename deploy-old
Defensive patterns

Strategy: validation

Validate before calling

if edit.rename.as_ref().is_some_and(|n| n != &edit.name)
    && script_db.get_by_name(edit.rename.as_ref().unwrap()).await?.is_some() {
    eprintln!("name already taken");
    return Ok(());
}

Prevention

When it happens

Trigger: `atuin script edit <name> --rename <new>` where `get_by_name(new)` returns Some for a different script.

Common situations: 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.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of atuinsh/atuin@900007c480 (2026-09-19). Data as JSON: /api/errors/bdd03fec0f9986c5. Report an issue: GitHub.

Appendix: source

Thrown at crates/atuin/src/command/client/scripts.rs:461

        script_store: ScriptStore,
        script_db: atuin_scripts::database::Database,
    ) -> Result<()> {
        debug!("editing script {:?}", edit);
        // Find the existing script
        let existing_script = script_db.get_by_name(&edit.name).await?;
        debug!("existing script {:?}", existing_script);

        if let Some(mut script) = existing_script {
            // Update the script with new values if provided
            if let Some(description) = edit.description {
                script.description = description;
            }

            // Handle renaming if requested
            if let Some(new_name) = edit.rename {
                // Check if a script with the new name already exists
                if (script_db.get_by_name(&new_name).await?).is_some() {
                    bail!("A script named '{}' already exists", new_name);
                }

                // Update the name
                script.name = new_name;
            }

            // Handle tag updates with priority:
            // 1. If --no-tags is provided, clear all tags
            // 2. If --tags is provided, replace all tags
            // 3. If neither is provided, tags remain unchanged
            if edit.no_tags {
                // Clear all tags
                script.tags.clear();
            } else if !edit.tags.is_empty() {
                // Replace all tags
                script.tags = edit.tags;
            }
            // If none of the above conditions are met, tags remain unchanged

View on GitHub (pinned to 900007c480)