@@ -316,6 +316,7 @@ use std::collections::hash_map::{Entry, HashMap};
316
316
use std:: convert:: TryInto ;
317
317
use std:: env;
318
318
use std:: hash:: { self , Hash , Hasher } ;
319
+ use std:: io;
319
320
use std:: path:: { Path , PathBuf } ;
320
321
use std:: str;
321
322
use std:: sync:: { Arc , Mutex } ;
@@ -1366,11 +1367,19 @@ fn calculate_run_custom_build(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoRes
1366
1367
let local = ( gen_local) (
1367
1368
deps,
1368
1369
Some ( & || {
1369
- pkg_fingerprint ( cx. bcx , & unit. pkg ) . with_context ( || {
1370
- format ! (
1371
- "failed to determine package fingerprint for build script for {}" ,
1372
- unit. pkg
1373
- )
1370
+ const IO_ERR_MESSAGE : & str = "\
1371
+ An I/O error happened. Please make sure you can access the file.
1372
+
1373
+ By default, if your project contains a build script, cargo scans all files in
1374
+ it to determine whether a rebuild is needed. If you don't expect to access the
1375
+ file, specify `rerun-if-changed` in your build script.
1376
+ See https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-changed for more information." ;
1377
+ pkg_fingerprint ( cx. bcx , & unit. pkg ) . map_err ( |err| {
1378
+ let mut message = format ! ( "failed to determine package fingerprint for build script for {}" , unit. pkg) ;
1379
+ if err. root_cause ( ) . is :: < io:: Error > ( ) {
1380
+ message = format ! ( "{}\n {}" , message, IO_ERR_MESSAGE )
1381
+ }
1382
+ err. context ( message)
1374
1383
} )
1375
1384
} ) ,
1376
1385
) ?
0 commit comments