cross-rs/cross · warning

using both `CROSS_CONTAINER_IN_CONTAINER` and…

Error message

using both `CROSS_CONTAINER_IN_CONTAINER` and `CROSS_DOCKER_IN_DOCKER`.

What it means

in_docker reads the container-in-container flag. `CROSS_DOCKER_IN_DOCKER` is the deprecated name and `CROSS_CONTAINER_IN_CONTAINER` the engine-agnostic one. Setting both is ambiguous, so cross warns and continues, preferring the new variable's value.

Solutions

  1. Remove CROSS_DOCKER_IN_DOCKER from your environment and keep only CROSS_CONTAINER_IN_CONTAINER.
  2. Update CI pipelines, Makefiles, and shell profiles that still export the deprecated variable.
  3. If both must be handled temporarily, ensure they hold the same value so the ambiguity is harmless.

Example fix

// before
export CROSS_CONTAINER_IN_CONTAINER=1
export CROSS_DOCKER_IN_DOCKER=1

// after
export CROSS_CONTAINER_IN_CONTAINER=1
Defensive patterns

Strategy: validation

Validate before calling

# in CI or shell profile
if [ -n "$CROSS_DOCKER_IN_DOCKER" ] && [ -n "$CROSS_CONTAINER_IN_CONTAINER" ]; then
  echo "Set only CROSS_CONTAINER_IN_CONTAINER"; exit 1
fi

Prevention

When it happens

Trigger: Calling in_docker (during any cross run that queries the engine mode) with both CROSS_CONTAINER_IN_CONTAINER and CROSS_DOCKER_IN_DOCKER present in the environment.

Common situations: Shell profile or CI config set the old variable and the user/tooling later added the new one; migrating scripts from old cross versions where CROSS_DOCKER_IN_DOCKER was the only name.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


AI-assisted analysis of cross-rs/cross@8c1a8aa4b6 (2026-09-13). Data as JSON: /api/errors/45fd4f0aaf9712a2. Report an issue: GitHub.

Appendix: source

Thrown at src/docker/engine.rs:120

            kind,
            in_docker,
            arch,
            os,
            is_remote,
            is_rootless,
        })
    }

    #[must_use]
    pub fn needs_remote(&self) -> bool {
        self.is_remote && self.kind == EngineType::Podman
    }

    pub fn in_docker(msg_info: &mut MessageInfo) -> Result<bool> {
        Ok(
            if let Ok(value) = env::var("CROSS_CONTAINER_IN_CONTAINER") {
                if env::var("CROSS_DOCKER_IN_DOCKER").is_ok() {
                    msg_info.warn(
                        "using both `CROSS_CONTAINER_IN_CONTAINER` and `CROSS_DOCKER_IN_DOCKER`.",
                    )?;
                }
                bool_from_envvar(&value)
            } else if let Ok(value) = env::var("CROSS_DOCKER_IN_DOCKER") {
                // FIXME: remove this when we deprecate CROSS_DOCKER_IN_DOCKER.
                bool_from_envvar(&value)
            } else {
                false
            },
        )
    }

    #[must_use]
    pub fn is_remote() -> bool {
        env::var("CROSS_REMOTE")
            .map(|s| bool_from_envvar(&s))
            .unwrap_or_default()

View on GitHub (pinned to 8c1a8aa4b6)