zed-industries/zed · error

A file (not a skill directory) already exists at

Error message

A file (not a skill directory) already exists at {}. Delete it or pick a different skill name.

What it means

Guard in write_skill_to_disk: something exists at the target path but it is a regular file, not a directory, so the skill directory cannot be created there. The error tells the user to delete the stray file or pick another name.

Solutions

  1. Delete the stray file at the reported path and retry saving
  2. Choose a different skill name that does not collide
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/settings_ui/src/pages/skill_creator.rs:1219 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20). Data as JSON: /api/errors/cf65fc6feb5f0fde. Report an issue: GitHub.

Appendix: source

Thrown at crates/settings_ui/src/pages/skill_creator.rs:1213

    description: &str,
    body: &str,
    disable_model_invocation: bool,
) -> Result<PathBuf> {
    let skill_dir = skills_dir.join(name);
    match fs.metadata(&skill_dir).await {
        Ok(Some(metadata)) if metadata.is_dir => {
            anyhow::bail!(
                "A skill named \"{name}\" already exists at {}. Pick a different name.",
                skill_dir.display()
            );
        }
        Ok(Some(_)) => {
            // Something exists at this path, but it isn't a directory — e.g.
            // a stray file the user (or another tool) left there. Without
            // this branch we'd fall through to `create_dir`, which on the
            // real fs returns a generic "File exists" IO error that gives
            // the user no idea what's wrong or how to recover.
            anyhow::bail!(
                "A file (not a skill directory) already exists at {}. \
                 Delete it or pick a different skill name.",
                skill_dir.display()
            );
        }
        Ok(None) => {}
        Err(err) => {
            return Err(err).with_context(|| {
                format!(
                    "failed to check whether {} already exists",
                    skill_dir.display()
                )
            });
        }
    }

    let content = format_skill_file(name, description, body, disable_model_invocation)?;

View on GitHub (pinned to 9d272b0363)