atuinsh/atuin · error

A script named '{}' already exists

Error message

A script named '{}' already exists

What it means

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.

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 c0c717ab04)

Solutions

  1. Choose a different, unique new name.
  2. Run `atuin scripts list` to confirm which names are taken.
  3. Delete the conflicting script first (`atuin scripts delete NEW`) if it's no longer wanted, then retry the rename.

Example fix

// before
atuin scripts edit deploy --rename deploy
// after
atuin scripts edit deploy --rename deploy-v2
Defensive patterns

Strategy: validation

Validate before calling

# shell
atuin scripts list | grep -qx "$new_name" && { echo "name '$new_name' already taken" >&2; exit 1; }
atuin scripts edit "$old" --rename "$new_name"

Try / catch

if ! atuin scripts edit "$old" --rename "$new" 2>&1; then
  echo "pick a unique name; current names:"; atuin scripts list
fi

Prevention

When it happens

Trigger: Running `atuin scripts edit OLD --rename NEW` where `script_db.get_by_name(NEW)` already returns a script.

Common situations: Trying to rename to a name that already exists (perhaps on another machine, then synced), or accidentally reusing an old script's name.

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@c0c717ab04 (2026-09-12). Data as JSON: /api/errors/bdd03fec0f9986c5. Report an issue: GitHub.