cross-rs/cross · warning
artifact path does not start with , skipping
Error message
artifact path {artifact_path} does not start with {mount_target_dir}, skipping What it means
After running a remote build, copy_artifacts_from_container lists produced artifacts and maps each container path to a host path by locating the mount target directory prefix. Any artifact path that does not contain the mount prefix cannot be mapped, so it is warned about and skipped rather than failing the run.
Solutions
- Ensure the build's target directory is the default (/target inside the container mount) — unset custom CARGO_TARGET_DIR overrides.
- Check cross's target mount options in Cross.toml / CLI flags so mount_target_dir matches where cargo actually writes artifacts.
- Inspect the build for scripts that copy artifacts to other paths and correct them.
- Update cross if a recent change altered the mount layout.
Example fix
# before CARGO_TARGET_DIR=/custom/target cross build --target aarch64-unknown-linux-gnu # after — let cross manage the target dir unset CARGO_TARGET_DIR cross build --target aarch64-unknown-linux-gnu
Defensive patterns
Strategy: validation
Validate before calling
# Before a remote build, make sure no custom target dir leaks in
if [ -n "${CARGO_TARGET_DIR:-}" ]; then
echo "CARGO_TARGET_DIR must be unset for cross remote builds"; exit 1
fi Try / catch
// Treat skipped artifacts as suspicious; fail if no artifacts were copied
let copied = copy_artifacts_from_container(...)?;
if copied.is_empty() { return Err(anyhow!("no artifacts mapped from container")); } Prevention
- Never set CARGO_TARGET_DIR for cross remote builds
- Keep build scripts writing only into the standard target dir
- Verify artifact paths in CI logs when the warning appears
When it happens
Trigger: During run (remote build), an artifact path reported by the container does not contain mount_target_dir, so `artifact_path.find(mount_target_dir)` returns None and the artifact is skipped.
Common situations: Custom target-dir or CARGO_TARGET_DIR settings inside the container placing artifacts outside the mounted /target; build scripts writing outputs to unexpected locations; misconfigured artifact mounting in cross options.
Related errors
- source is pointing to a directory instead of its contents
- workspace_root can't end in `..`
- copied directory contained symlinks. if the volume the link…
- remote and docker-in-docker are unlikely to work together…
- a persistent volume does not exists for
AI-assisted analysis of cross-rs/cross@8c1a8aa4b6 (2026-09-13).
Data as JSON: /api/errors/6d6b50a04099a930.
Report an issue: GitHub.
Appendix: source
Thrown at src/docker/remote.rs:597
fn copy_artifacts_from_container(
engine: &Engine,
container_id: &str,
artifact_files: &[String],
host_target_dir: &Path,
mount_target_dir: &str,
msg_info: &mut MessageInfo,
) -> Result<()> {
for artifact_path in artifact_files {
let artifact_path = artifact_path.trim();
if artifact_path.is_empty() {
continue;
}
let relative = if let Some(pos) = artifact_path.find(mount_target_dir) {
&artifact_path[pos + mount_target_dir.len()..]
} else {
msg_info.warn(format_args!(
"artifact path {artifact_path} does not start with {mount_target_dir}, skipping"
))?;
continue;
};
let host_path = host_target_dir.join(relative.trim_start_matches('/'));
if let Some(parent) = host_path.parent() {
fs::create_dir_all(parent)?;
}
subcommand_or_exit(engine, "cp")?
.arg(format!("{container_id}:{artifact_path}"))
.arg(&host_path)
.run_and_get_status(msg_info, false)?;
}
Ok(())
}View on GitHub (pinned to 8c1a8aa4b6)