diff --git a/src/docker/mod.rs b/src/docker/mod.rs index b341736f4..f2c9da22e 100644 --- a/src/docker/mod.rs +++ b/src/docker/mod.rs @@ -41,6 +41,7 @@ pub fn run( docker_in_docker, cwd, ) + .wrap_err("could not complete remote run") } else { local::run( engine, diff --git a/src/docker/remote.rs b/src/docker/remote.rs index 2167ed513..5994be4a7 100644 --- a/src/docker/remote.rs +++ b/src/docker/remote.rs @@ -4,6 +4,8 @@ use std::path::{Path, PathBuf}; use std::process::ExitStatus; use std::{env, fs, time}; +use eyre::Context; + use super::engine::Engine; use super::shared::*; use crate::cargo::CargoMetadata; @@ -130,7 +132,7 @@ fn copy_volume_files( .arg(src.to_utf8()?) .arg(format!("{container}:{}", dst.as_posix()?)) .run_and_get_status(msg_info, false) - .map_err(Into::into) + .map(Into::into) } fn is_cachedir_tag(path: &Path) -> Result { @@ -221,9 +223,15 @@ pub fn copy_volume_container_cargo( } else { // can copy a limit subset of files: the rest is present. create_volume_dir(engine, container, &dst, msg_info)?; - for entry in fs::read_dir(cargo_dir)? { + for entry in fs::read_dir(cargo_dir) + .wrap_err_with(|| format!("when reading directory {cargo_dir:?}"))? + { let file = entry?; - let basename = file.file_name().to_utf8()?.to_string(); + let basename = file + .file_name() + .to_utf8() + .wrap_err_with(|| format!("when reading file {file:?}"))? + .to_string(); if !basename.starts_with('.') && !matches!(basename.as_ref(), "git" | "registry") { copy_volume_files(engine, container, &file.path(), &dst, msg_info)?; } @@ -238,7 +246,7 @@ fn copy_dir(src: &Path, dst: &Path, depth: u32, skip: Skip) -> Result<()> where Skip: Copy + Fn(&fs::DirEntry, u32) -> bool, { - for entry in fs::read_dir(src)? { + for entry in fs::read_dir(src).wrap_err_with(|| format!("when reading directory {src:?}"))? { let file = entry?; if skip(&file, depth) { continue; @@ -247,7 +255,8 @@ where let src_path = file.path(); let dst_path = dst.join(file.file_name()); if file.file_type()?.is_file() { - fs::copy(&src_path, &dst_path)?; + fs::copy(&src_path, &dst_path) + .wrap_err_with(|| format!("when copying file {src_path:?} -> {dst_path:?}"))?; } else { fs::create_dir(&dst_path).ok(); copy_dir(&src_path, &dst_path, depth + 1, skip)?; @@ -755,7 +764,7 @@ pub(crate) fn run( // 2. create our volume to copy all our data over to if let VolumeId::Discard(ref id) = volume { - volume_create(engine, id, msg_info)?; + volume_create(engine, id, msg_info).wrap_err("when creating volume")?; } let _volume_deletter = DeleteVolume(engine, &volume, msg_info); @@ -775,9 +784,11 @@ pub(crate) fn run( cwd, |_, val| mount_path(val), |(src, dst)| volumes.push((src, dst)), - )?; + ) + .wrap_err("could not determine mount points")?; - docker_seccomp(&mut docker, engine.kind, target, metadata)?; + docker_seccomp(&mut docker, engine.kind, target, metadata) + .wrap_err("when copying seccomp profile")?; // Prevent `bin` from being mounted inside the Docker container. docker.args(&["-v", &format!("{mount_prefix}/cargo/bin")]); @@ -821,7 +832,8 @@ pub(crate) fn run( target, mount_prefix_path, msg_info, - )?; + ) + .wrap_err("when copying xargo")?; copy_volume_container_cargo( engine, &container, @@ -829,7 +841,8 @@ pub(crate) fn run( mount_prefix_path, false, msg_info, - )?; + ) + .wrap_err("when copying cargo")?; copy_volume_container_rust( engine, &container, @@ -838,7 +851,8 @@ pub(crate) fn run( mount_prefix_path, false, msg_info, - )?; + ) + .wrap_err("when copying rust")?; } else { // need to copy over the target triple if it hasn't been previously copied copy_volume_container_rust_triple( @@ -849,14 +863,16 @@ pub(crate) fn run( mount_prefix_path, true, msg_info, - )?; + ) + .wrap_err("when copying rust target files")?; } let mount_root = if mount_volumes { // cannot panic: absolute unix path, must have root let rel_mount_root = dirs.mount_root.strip_prefix('/').unwrap(); let mount_root = mount_prefix_path.join(rel_mount_root); if !rel_mount_root.is_empty() { - create_volume_dir(engine, &container, mount_root.parent().unwrap(), msg_info)?; + create_volume_dir(engine, &container, mount_root.parent().unwrap(), msg_info) + .wrap_err("when creating mount root")?; } mount_root } else { diff --git a/src/lib.rs b/src/lib.rs index c3db3954d..419db5d02 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -518,7 +518,8 @@ pub fn run() -> Result { args.msg_info, args.docker_in_docker, &cwd, - )?; + ) + .wrap_err("when running docker")?; let needs_host = args .subcommand .map(|sc| sc.needs_host(is_remote))