astral-sh/uv · error

`{}` is already a PEP 723 script; use `{}` to execute it

Error message

`{}` is already a PEP 723 script; use `{}` to execute it

What it means

Error "`{}` is already a PEP 723 script; use `{}` to execute it" thrown in astral-sh/uv.

Source

Thrown at crates/uv/src/commands/project/init.rs:230

    config_discovery: ConfigDiscovery,
) -> Result<()> {
    if no_workspace {
        warn_user_once!("`--no-workspace` is a no-op for Python scripts, which are standalone");
    }
    if no_readme {
        warn_user_once!("`--no-readme` is a no-op for Python scripts, which are standalone");
    }
    if author_from.is_some() {
        warn_user_once!("`--author-from` is a no-op for Python scripts, which are standalone");
    }
    let reporter = PythonDownloadReporter::single(printer);

    // If the file already exists, read its content.
    let content = match fs_err::tokio::read(script_path).await {
        Ok(metadata) => {
            // If the file is already a script, raise an error.
            if ScriptTag::parse(&metadata)?.is_some() {
                anyhow::bail!(
                    "`{}` is already a PEP 723 script; use `{}` to execute it",
                    script_path.simplified_display().cyan(),
                    "uv run".green()
                );
            }

            Some(metadata)
        }
        Err(err) if err.kind() == std::io::ErrorKind::NotFound => None,
        Err(err) => {
            return Err(err).with_context(|| {
                format!(
                    "Failed to read script at `{}`",
                    script_path.simplified_display().cyan()
                )
            });
        }
    };

View on GitHub (pinned to f1a42680ff)

When it happens

Trigger: Thrown at crates/uv/src/commands/project/init.rs:230 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of astral-sh/uv@f1a42680ff (2026-08-16). Data as JSON: /api/errors/8323bb962e43e910. Report an issue: GitHub.