{"record":{"id":"791e4afd0240585e","repo":"warpdotdev/warp","slug":"error-selecting-environment-err","errorCode":null,"errorMessage":"Error selecting environment: {err}","messagePattern":"Error selecting environment: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/common.rs","lineNumber":292,"sourceCode":"                let cli_name = warp_cli::binary_name().unwrap_or_else(|| \"warp\".to_string());\n                return Err(ResolveConfigurationError::Other(anyhow::anyhow!(\n                    \"No environments are configured for this account.\\n\\\nYou can create an environment with `{cli_name} environment create`.\\n\\\nOr, re-run this command with `--no-environment` to not use an environment.\\n\\\nWithout an environment, the agent will not be able to access private repositories or create pull requests.\",\n                )));\n            }\n\n            let prompt = \"Select an environment to run the agent in (or 'No environment'):\";\n\n            let choice = Select::new(prompt, options).prompt();\n\n            match choice {\n                Ok(choice) => Ok(choice),\n                Err(InquireError::OperationCanceled | InquireError::OperationInterrupted) => {\n                    Err(ResolveConfigurationError::Canceled)\n                }\n                Err(err) => Err(ResolveConfigurationError::Other(anyhow::anyhow!(\n                    \"Error selecting environment: {err}\"\n                ))),\n            }\n        }\n    }\n\n    /// Resolve the environment to use when updating an agent integration. If the user did not\n    /// request any changes to the environment, this returns `Ok(None)`.\n    /// Warp Drive *must* have been synced first.\n    pub fn resolve_for_update(\n        args: EnvironmentUpdateArgs,\n        ctx: &AppContext,\n    ) -> Result<Option<Self>, ResolveConfigurationError> {\n        if args.remove_environment {\n            Ok(Some(EnvironmentChoice::None))\n        } else if let Some(id) = args.environment {\n            Self::get_by_id(id, ctx).map(Some)\n        } else {","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/common.rs#L274-L310","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run the command in a real interactive terminal (attach a TTY) so the Select prompt can render and read input.","Avoid the prompt entirely by passing the environment explicitly (e.g. --environment <name>) or --no-environment in non-interactive contexts.","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."],"exampleFix":"// before (CLI invocation that triggers the interactive picker)\nwarp agent create\n\n// after (non-interactive: skip the prompt)\nwarp agent create --no-environment\nwarp agent create --environment my-env","handlingStrategy":"try-catch","validationCode":"if !std::io::IsTerminal::is_terminal(&std::io::stdout()) || !std::io::IsTerminal::is_terminal(&std::io::stdin()) {\n    anyhow::bail!(\"environment selection requires a TTY; pass --environment or --no-environment\");\n}","typeGuard":null,"tryCatchPattern":"match select_environment(options) {\n    Err(ResolveConfigurationError::Canceled) => Ok(None), // user aborted, not an error to log\n    Err(ResolveConfigurationError::Other(err)) if err.to_string().contains(\"Error selecting environment\") => {\n        log::warn!(\"environment prompt failed: {err:#}\");\n        Ok(None)\n    }\n    rest => rest,\n}","preventionTips":["Pass --environment/--no-environment in scripts, CI, and daemons so no prompt is attempted.","Check TTY availability before launching interactive flows.","Keep the Canceled-vs-error distinction: only the latter indicates a terminal/IO problem."],"tags":["interactive","terminal","cli","rust","environment-selection"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}