vectordotdev/vector · error

No environment for is up.

Error message

No environment for {} is up.

What it means

`ComposeTest::stop` requires the environment to be running; if `is_running()` reports it is not, stopping is pointless and it bails with the test name. This avoids issuing meaningless compose stop commands and surfaces state confusion early.

Solutions

  1. Only call stop after a successful start (guard with is_running in your script)
  2. If already stopped, no action is needed — ignore or remove the redundant stop call
  3. If containers should be running, investigate why they exited (docker logs, compose ps)
  4. Restart the environment with `cargo vdev int start` if you intended to cycle it

Example fix

// before
compose_test.stop(); // called when never started
// after
if compose_test.is_running()? {
    compose_test.stop()?;
}
Defensive patterns

Strategy: validation

Validate before calling

if !compose_test.is_running()? {
    // nothing to stop; skip or start first
    return Ok(());
}
compose_test.stop()?;

Try / catch

match result {
    Err(e) if e.to_string().starts_with("No environment for") => {
        // already stopped; treat as no-op
        Ok(())
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling `stop()` when the compose project was never started or was already stopped/removed.

Common situations: Calling stop after a failed start; stop called twice (e.g. duplicate cleanup); docker containers exited on their own; running stop in a fresh environment before start.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/39162d13448c6926. Report an issue: GitHub.

Appendix: source

Thrown at vdev/src/testing/integration.rs:288

        self.config.check_required()?;
        if let Some(compose) = &self.compose {
            self.runner.ensure_network()?;
            self.runner.ensure_external_volumes()?;

            if self.is_running()? {
                bail!("environment is already up");
            }

            let project_name = self.project_name();
            compose.start(&self.env_config, &project_name)?;
        }
        Ok(())
    }

    pub(crate) fn stop(&self) -> Result<()> {
        if let Some(compose) = &self.compose {
            if !self.is_running()? {
                bail!("No environment for {} is up.", self.test_name);
            }

            let project_name = self.project_name();
            compose.stop(&self.env_config, &project_name)?;
        }

        self.runner.remove()?;

        Ok(())
    }

    fn logs(&self) -> Result<Option<ExitStatus>> {
        let Some(compose) = &self.compose else {
            return Ok(None);
        };

        compose
            .logs(&self.env_config, &self.project_name())

View on GitHub (pinned to bdb87aeaa4)