warpdotdev/warp · error · anyhow::Error

Error selecting environment: {err}

Error message

Error selecting environment: {err}

What it means

Wraps any InquireError from the interactive Select prompt for environments that is not OperationCanceled/OperationInterrupted — i.e. the prompt itself failed rather than the user aborting. Typical causes are std::io errors on the terminal (not a TTY, closed stdin/stdout) or other inquire-level failures. Canceled/interrupted are deliberately mapped to ResolveConfigurationError::Canceled instead.

Source

Thrown at app/src/ai/agent_sdk/common.rs:292

                let cli_name = warp_cli::binary_name().unwrap_or_else(|| "warp".to_string());
                return Err(ResolveConfigurationError::Other(anyhow::anyhow!(
                    "No environments are configured for this account.\n\
You can create an environment with `{cli_name} environment create`.\n\
Or, re-run this command with `--no-environment` to not use an environment.\n\
Without an environment, the agent will not be able to access private repositories or create pull requests.",
                )));
            }

            let prompt = "Select an environment to run the agent in (or 'No environment'):";

            let choice = Select::new(prompt, options).prompt();

            match choice {
                Ok(choice) => Ok(choice),
                Err(InquireError::OperationCanceled | InquireError::OperationInterrupted) => {
                    Err(ResolveConfigurationError::Canceled)
                }
                Err(err) => Err(ResolveConfigurationError::Other(anyhow::anyhow!(
                    "Error selecting environment: {err}"
                ))),
            }
        }
    }

    /// Resolve the environment to use when updating an agent integration. If the user did not
    /// request any changes to the environment, this returns `Ok(None)`.
    /// Warp Drive *must* have been synced first.
    pub fn resolve_for_update(
        args: EnvironmentUpdateArgs,
        ctx: &AppContext,
    ) -> Result<Option<Self>, ResolveConfigurationError> {
        if args.remove_environment {
            Ok(Some(EnvironmentChoice::None))
        } else if let Some(id) = args.environment {
            Self::get_by_id(id, ctx).map(Some)
        } else {

View on GitHub (pinned to e72fd7aacb)

Solutions

  1. Run the command in a real interactive terminal (attach a TTY) so the Select prompt can render and read input.
  2. Avoid the prompt entirely by passing the environment explicitly (e.g. --environment <name>) or --no-environment in non-interactive contexts.
  3. If it fails in a real terminal, check that stdin/stdout are not redirected and TERM is set; the underlying {err} describes the IO failure.

Example fix

// before (CLI invocation that triggers the interactive picker)
warp agent create

// after (non-interactive: skip the prompt)
warp agent create --no-environment
warp agent create --environment my-env
Defensive patterns

Strategy: try-catch

Validate before calling

if !std::io::IsTerminal::is_terminal(&std::io::stdout()) || !std::io::IsTerminal::is_terminal(&std::io::stdin()) {
    anyhow::bail!("environment selection requires a TTY; pass --environment or --no-environment");
}

Try / catch

match select_environment(options) {
    Err(ResolveConfigurationError::Canceled) => Ok(None), // user aborted, not an error to log
    Err(ResolveConfigurationError::Other(err)) if err.to_string().contains("Error selecting environment") => {
        log::warn!("environment prompt failed: {err:#}");
        Ok(None)
    }
    rest => rest,
}

Prevention

When it happens

Trigger: Calling Select::new(prompt, options).prompt() when stdout/stdin is not an interactive terminal (piped output, CI, daemon context), or when the terminal is lost mid-prompt (ssh drop), producing an InquireError::IO variant that falls into the catch-all Err(err) arm.

Common situations: Running warp CLI commands from scripts/CI where no TTY is attached; piping output; running under a process supervisor; or an environment where TERM is unset so the prompt library cannot render.

Related errors


AI-assisted analysis of warpdotdev/warp@e72fd7aacb (2026-08-16). Data as JSON: /api/errors/791e4afd0240585e. Report an issue: GitHub.