{"record":{"id":"6b44095edeae5955","repo":"cross-rs/cross","slug":"using-both-cross-container-opts-and-docker-opts","errorCode":null,"errorMessage":"using both `CROSS_CONTAINER_OPTS` and `DOCKER_OPTS`.","messagePattern":"using both `CROSS_CONTAINER_OPTS` and `DOCKER_OPTS`\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/docker/shared.rs","lineNumber":1034,"sourceCode":"            .args([\n                \"-e\",\n                &format!(\"CROSS_RUST_SYSROOT={}\", dirs.sysroot_mount_path()),\n            ])\n            .args([\"-e\", \"CARGO_TARGET_DIR=/target\"])\n            .args([\"-e\", &cross_runner]);\n        if options.command_variant.uses_zig() {\n            // otherwise, zig has a permission error trying to create the cache\n            self.args([\"-e\", \"XDG_CACHE_HOME=/target/.zig-cache\"]);\n        }\n        self.add_configuration_envvars();\n\n        if let Some(username) = id::username().wrap_err(\"could not get username\")? {\n            self.args([\"-e\", &format!(\"USER={username}\")]);\n        }\n\n        if let Ok(value) = env::var(\"CROSS_CONTAINER_OPTS\") {\n            if env::var(\"DOCKER_OPTS\").is_ok() {\n                msg_info.warn(\"using both `CROSS_CONTAINER_OPTS` and `DOCKER_OPTS`.\")?;\n            }\n            self.args(&Engine::parse_opts(&value)?);\n        } else if let Ok(value) = env::var(\"DOCKER_OPTS\") {\n            // FIXME: remove this when we deprecate DOCKER_OPTS.\n            self.args(&Engine::parse_opts(&value)?);\n        };\n\n        let (major, minor, patch) = match options.rustc_version.as_ref() {\n            Some(version) => (version.major, version.minor, version.patch),\n            // no toolchain version available, always provide the oldest\n            // compiler available. this isn't a major issue because\n            // linking with libgcc will not include symbols found in\n            // the builtins.\n            None => (1, 0, 0),\n        };\n        self.args([\"-e\", &format!(\"CROSS_RUSTC_MAJOR_VERSION={}\", major)]);\n        self.args([\"-e\", &format!(\"CROSS_RUSTC_MINOR_VERSION={}\", minor)]);\n        self.args([\"-e\", &format!(\"CROSS_RUSTC_PATCH_VERSION={}\", patch)]);","sourceCodeStart":1016,"sourceCodeEnd":1052,"githubUrl":"https://github.com/cross-rs/cross/blob/8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27/src/docker/shared.rs#L1016-L1052","documentation":"Warning emitted when the user has set both CROSS_CONTAINER_OPTS and DOCKER_OPTS in the environment. CROSS_CONTAINER_OPTS is the supported, engine-agnostic variable; DOCKER_OPTS is the older Docker-only one. Setting both is ambiguous because only one can take effect, so cross warns and proceeds rather than silently ignoring the configuration.","triggerScenarios":"Thrown at src/docker/shared.rs:1034 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Unset DOCKER_OPTS and keep only CROSS_CONTAINER_OPTS so the options apply regardless of the container engine used","If you specifically rely on DOCKER_OPTS semantics, remove CROSS_CONTAINER_OPTS to silence the warning","Move the shared options into cross's configuration file instead of environment variables to avoid the conflict"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27","analyzedAt":"2026-09-13T15:10:43.988Z","contentChangedAt":"2026-09-13T15:10:43.988Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}