Repository: astral-sh/uv
File: crates/uv/src/commands/pip/install.rs (Rust)

Code before:
            "Using `--target` directory at {}",
            target.root().user_display()
        );
        environment.with_target(target)?
    } else if let Some(prefix) = prefix {
        debug!(
            "Using `--prefix` directory at {}",
            prefix.root().user_display()
        );
        environment.with_prefix(prefix)?
    } else {
        environment
    };

    // If the environment is externally managed, abort.
    if let Some(externally_managed) = environment.interpreter().is_externally_managed() {
        if break_system_packages {
            debug!("Ignoring externally managed environment due to `--break-system-packages`");
        } else {
            let error = match externally_managed.into_error() {
                Some(error) => anyhow::anyhow!(
                    "The interpreter at {} is externally managed, and indicates the following:\n\n{}\n\nConsider creating a virtual environment with `uv venv`.{}",
                    environment.root().user_display().cyan(),
                    textwrap::indent(&error, "  ").green(),
                    if system {
                        "\nhint: This happens because you used the `--system` flag, which selects the system Python interpreter."
                    } else {
                        ""
                    }
                ),
                None => anyhow::anyhow!(
                    "The interpreter at {} is externally managed. Instead, create a virtual environment with `uv venv`.",
                    environment.root().user_display().cyan()
                ),
            };
            return Err(error);
        }
    }

    let _lock = environment
        .lock()
        .await
        .inspect_err(|err| {
            warn!("Failed to acquire environment lock: {err}");
        })
        .ok();

    // Determine the markers and tags to use for the resolution.
    let interpreter = environment.interpreter();
    let marker_env = resolution_markers(
        python_version.as_ref(),

Review comment (suggestion):
What about the following hint:

> The `--system` flag was used

We usually use indirect language instead of "you used"

Code after:
            "Using `--target` directory at {}",
            target.root().user_display()
        );
        environment.with_target(target)?
    } else if let Some(prefix) = prefix {
        debug!(
            "Using `--prefix` directory at {}",
            prefix.root().user_display()
        );
        environment.with_prefix(prefix)?
    } else {
        environment
    };

    // If the environment is externally managed, abort.
    if let Some(externally_managed) = environment.interpreter().is_externally_managed() {
        if break_system_packages {
            debug!("Ignoring externally managed environment due to `--break-system-packages`");
        } else {
            let base_message = match externally_managed.into_error() {
                Some(error) => format!(
                    "The interpreter at {} is externally managed, and indicates the following:\n\n{}\n\nConsider creating a virtual environment with `uv venv`.",
                    environment.root().user_display().cyan(),
                    textwrap::indent(&error, "  ").green(),
                ),
                None => format!(
                    "The interpreter at {} is externally managed. Instead, create a virtual environment with `uv venv`.",
                    environment.root().user_display().cyan()
                ),
            };

            let error_message = if system {
                format!(
                    "{}\n{}{} This happens because the `--system` flag was used, which selected the system Python interpreter.",
                    base_message,
                    "hint".bold().cyan(),
                    ":".bold()
                )
            } else {
                base_message
            };

            return Err(anyhow::Error::msg(error_message));
        }
    }

    let _lock = environment
        .lock()
        .await
        .inspect_err(|err| {
            warn!("Failed to acquire environment lock: {err}");