@@ -4,6 +4,8 @@ use std::path::{Path, PathBuf};
4
4
use std:: process:: ExitStatus ;
5
5
use std:: { env, fs, time} ;
6
6
7
+ use eyre:: Context ;
8
+
7
9
use super :: engine:: Engine ;
8
10
use super :: shared:: * ;
9
11
use crate :: cargo:: CargoMetadata ;
@@ -114,7 +116,6 @@ fn create_volume_dir(
114
116
. arg ( container)
115
117
. args ( & [ "sh" , "-c" , & format ! ( "mkdir -p '{}'" , dir. as_posix( ) ?) ] )
116
118
. run_and_get_status ( msg_info, false )
117
- . map_err ( Into :: into)
118
119
}
119
120
120
121
// copy files for a docker volume, for remote host support
@@ -130,7 +131,7 @@ fn copy_volume_files(
130
131
. arg ( src. to_utf8 ( ) ?)
131
132
. arg ( format ! ( "{container}:{}" , dst. as_posix( ) ?) )
132
133
. run_and_get_status ( msg_info, false )
133
- . map_err ( Into :: into)
134
+ . map ( Into :: into)
134
135
}
135
136
136
137
fn is_cachedir_tag ( path : & Path ) -> Result < bool > {
@@ -223,9 +224,15 @@ pub fn copy_volume_container_cargo(
223
224
} else {
224
225
// can copy a limit subset of files: the rest is present.
225
226
create_volume_dir ( engine, container, & dst, msg_info) ?;
226
- for entry in fs:: read_dir ( cargo_dir) ? {
227
+ for entry in fs:: read_dir ( cargo_dir)
228
+ . wrap_err_with ( || format ! ( "when reading directory {cargo_dir:?}" ) ) ?
229
+ {
227
230
let file = entry?;
228
- let basename = file. file_name ( ) . to_utf8 ( ) ?. to_string ( ) ;
231
+ let basename = file
232
+ . file_name ( )
233
+ . to_utf8 ( )
234
+ . wrap_err_with ( || format ! ( "when reading file {file:?}" ) ) ?
235
+ . to_string ( ) ;
229
236
if !basename. starts_with ( '.' ) && !matches ! ( basename. as_ref( ) , "git" | "registry" ) {
230
237
copy_volume_files ( engine, container, & file. path ( ) , & dst, msg_info) ?;
231
238
}
@@ -248,7 +255,7 @@ where
248
255
{
249
256
let mut had_symlinks = false ;
250
257
251
- for entry in fs:: read_dir ( src) ? {
258
+ for entry in fs:: read_dir ( src) . wrap_err_with ( || format ! ( "when reading directory {src:?}" ) ) ? {
252
259
let file = entry?;
253
260
if skip ( & file, depth) {
254
261
continue ;
@@ -257,7 +264,8 @@ where
257
264
let src_path = file. path ( ) ;
258
265
let dst_path = dst. join ( file. file_name ( ) ) ;
259
266
if file. file_type ( ) ?. is_file ( ) {
260
- fs:: copy ( & src_path, & dst_path) ?;
267
+ fs:: copy ( & src_path, & dst_path)
268
+ . wrap_err_with ( || format ! ( "when copying file {src_path:?} -> {dst_path:?}" ) ) ?;
261
269
} else if file. file_type ( ) ?. is_dir ( ) {
262
270
fs:: create_dir ( & dst_path) . ok ( ) ;
263
271
had_symlinks = copy_dir ( & src_path, & dst_path, copy_symlinks, depth + 1 , skip) ?;
@@ -604,7 +612,6 @@ rm \"{PATH}\"
604
612
. arg ( container)
605
613
. args ( & [ "sh" , "-c" , & script. join ( "\n " ) ] )
606
614
. run_and_get_status ( msg_info, true )
607
- . map_err ( Into :: into)
608
615
}
609
616
610
617
fn copy_volume_container_project (
@@ -657,7 +664,6 @@ fn run_and_get_status(engine: &Engine, args: &[&str], msg_info: MessageInfo) ->
657
664
command ( engine)
658
665
. args ( args)
659
666
. run_and_get_status ( msg_info, true )
660
- . map_err ( Into :: into)
661
667
}
662
668
663
669
pub fn volume_create ( engine : & Engine , volume : & str , msg_info : MessageInfo ) -> Result < ExitStatus > {
@@ -673,7 +679,6 @@ pub fn volume_exists(engine: &Engine, volume: &str, msg_info: MessageInfo) -> Re
673
679
. args ( & [ "volume" , "inspect" , volume] )
674
680
. run_and_get_output ( msg_info)
675
681
. map ( |output| output. status . success ( ) )
676
- . map_err ( Into :: into)
677
682
}
678
683
679
684
pub fn container_stop (
@@ -805,7 +810,7 @@ pub(crate) fn run(
805
810
806
811
// 2. create our volume to copy all our data over to
807
812
if let VolumeId :: Discard ( ref id) = volume {
808
- volume_create ( engine, id, msg_info) ?;
813
+ volume_create ( engine, id, msg_info) . wrap_err ( "when creating volume" ) ?;
809
814
}
810
815
let _volume_deletter = DeleteVolume ( engine, & volume, msg_info) ;
811
816
@@ -825,9 +830,11 @@ pub(crate) fn run(
825
830
cwd,
826
831
|_, val| mount_path ( val) ,
827
832
|( src, dst) | volumes. push ( ( src, dst) ) ,
828
- ) ?;
833
+ )
834
+ . wrap_err ( "could not determine mount points" ) ?;
829
835
830
- docker_seccomp ( & mut docker, engine. kind , target, metadata) ?;
836
+ docker_seccomp ( & mut docker, engine. kind , target, metadata)
837
+ . wrap_err ( "when copying seccomp profile" ) ?;
831
838
832
839
// Prevent `bin` from being mounted inside the Docker container.
833
840
docker. args ( & [ "-v" , & format ! ( "{mount_prefix}/cargo/bin" ) ] ) ;
@@ -871,15 +878,17 @@ pub(crate) fn run(
871
878
target,
872
879
mount_prefix_path,
873
880
msg_info,
874
- ) ?;
881
+ )
882
+ . wrap_err ( "when copying xargo" ) ?;
875
883
copy_volume_container_cargo (
876
884
engine,
877
885
& container,
878
886
& dirs. cargo ,
879
887
mount_prefix_path,
880
888
false ,
881
889
msg_info,
882
- ) ?;
890
+ )
891
+ . wrap_err ( "when copying cargo" ) ?;
883
892
copy_volume_container_rust (
884
893
engine,
885
894
& container,
@@ -888,7 +897,8 @@ pub(crate) fn run(
888
897
mount_prefix_path,
889
898
false ,
890
899
msg_info,
891
- ) ?;
900
+ )
901
+ . wrap_err ( "when copying rust" ) ?;
892
902
} else {
893
903
// need to copy over the target triple if it hasn't been previously copied
894
904
copy_volume_container_rust_triple (
@@ -899,14 +909,16 @@ pub(crate) fn run(
899
909
mount_prefix_path,
900
910
true ,
901
911
msg_info,
902
- ) ?;
912
+ )
913
+ . wrap_err ( "when copying rust target files" ) ?;
903
914
}
904
915
let mount_root = if mount_volumes {
905
916
// cannot panic: absolute unix path, must have root
906
917
let rel_mount_root = dirs. mount_root . strip_prefix ( '/' ) . unwrap ( ) ;
907
918
let mount_root = mount_prefix_path. join ( rel_mount_root) ;
908
919
if !rel_mount_root. is_empty ( ) {
909
- create_volume_dir ( engine, & container, mount_root. parent ( ) . unwrap ( ) , msg_info) ?;
920
+ create_volume_dir ( engine, & container, mount_root. parent ( ) . unwrap ( ) , msg_info)
921
+ . wrap_err ( "when creating mount root" ) ?;
910
922
}
911
923
mount_root
912
924
} else {
@@ -920,7 +932,8 @@ pub(crate) fn run(
920
932
& volume,
921
933
copy_cache,
922
934
msg_info,
923
- ) ?;
935
+ )
936
+ . wrap_err ( "when copying project" ) ?;
924
937
925
938
let mut copied = vec ! [
926
939
( & dirs. xargo, mount_prefix_path. join( "xargo" ) ) ,
0 commit comments