{"record":{"id":"d869cc4bd9e51db9","repo":"vectordotdev/vector","slug":"environment-is-already-up","errorCode":null,"errorMessage":"environment is already up","messagePattern":"environment is already up","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vdev/src/testing/integration.rs","lineNumber":276,"sourceCode":"    pub(crate) fn start(&self) -> Result<()> {\n        // For end-to-end tests, we want to run vector as a service, leveraging the\n        // image for the runner. So we must build that image before starting the\n        // compose so that it is available.\n        if self.local_config.kind == ComposeTestKind::E2E {\n            self.runner.build(\n                Some(&self.config.features),\n                &self.env_config,\n                true, // E2E tests build Vector in the image\n            )?;\n        }\n\n        self.config.check_required()?;\n        if let Some(compose) = &self.compose {\n            self.runner.ensure_network()?;\n            self.runner.ensure_external_volumes()?;\n\n            if self.is_running()? {\n                bail!(\"environment is already up\");\n            }\n\n            let project_name = self.project_name();\n            compose.start(&self.env_config, &project_name)?;\n        }\n        Ok(())\n    }\n\n    pub(crate) fn stop(&self) -> Result<()> {\n        if let Some(compose) = &self.compose {\n            if !self.is_running()? {\n                bail!(\"No environment for {} is up.\", self.test_name);\n            }\n\n            let project_name = self.project_name();\n            compose.stop(&self.env_config, &project_name)?;\n        }\n","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/vdev/src/testing/integration.rs#L258-L294","documentation":"`ComposeTest::start` refuses to start an environment whose containers are already running, detected via `is_running()`. Starting twice would conflict with the existing docker compose project, so it bails early with this clear message instead of a docker error.","triggerScenarios":"Calling `start()` (e.g. `cargo vdev int start <integration>`) when a previous start left the compose project up, or two invocations run concurrently.","commonSituations":"A previous test run crashed before calling stop; forgetting to run `cargo vdev int stop`; running start in two terminals at once; re-running a test script that assumes a clean state.","solutions":["Stop the environment first with `cargo vdev int stop <integration>`","Or tear down manually: `docker compose -p <project> down` in the test directory","Check `docker ps` for containers from a prior run and remove them","Ensure your test harness calls stop in a cleanup/finally step"],"exampleFix":"// before\ncargo vdev int start aws   # already running from previous run\n// after\ncargo vdev int stop aws && cargo vdev int start aws","handlingStrategy":"try-catch","validationCode":"use std::process::Command;\nfn compose_up(project: &str) -> bool {\n    Command::new(\"docker\")\n        .args([\"compose\", \"ls\", \"--format\", \"json\"])\n        .output()\n        .map(|o| String::from_utf8_lossy(&o.stdout).contains(project))\n        .unwrap_or(false)\n}\nif compose_up(\"vector-integration-tests-aws\") { /* stop first */ }","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"environment is already up\") => {\n        // treat as success: environment ready for use\n    }\n    other => other?,\n}","preventionTips":["Always pair start with stop in a cleanup/finally block","Run `cargo vdev int stop <integration>` before start in scripts for idempotency","Avoid concurrent integration test runs using the same docker project name","Check `docker ps` when a previous test run crashed"],"tags":["rust","docker-compose","integration-tests","state"],"backgroundTag":"invalid-state-transition","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}