mirror of
https://github.com/rust-lang/cargo
synced 2024-10-05 23:39:47 +00:00
Improve I/O error message for fingerprint of build script
It is a bit rough but I don't think there is a network I/O error in `pkg_fingerprint`. Checking only `io::Error` type should be fine.
This commit is contained in:
parent
40dc281755
commit
760ff62f36
|
@ -316,6 +316,7 @@ use std::collections::hash_map::{Entry, HashMap};
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::hash::{self, Hash, Hasher};
|
use std::hash::{self, Hash, Hasher};
|
||||||
|
use std::io;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
@ -1366,11 +1367,19 @@ fn calculate_run_custom_build(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoRes
|
||||||
let local = (gen_local)(
|
let local = (gen_local)(
|
||||||
deps,
|
deps,
|
||||||
Some(&|| {
|
Some(&|| {
|
||||||
pkg_fingerprint(cx.bcx, &unit.pkg).with_context(|| {
|
const IO_ERR_MESSAGE: &str = "\
|
||||||
format!(
|
An I/O error happened. Please make sure you can access the file.
|
||||||
"failed to determine package fingerprint for build script for {}",
|
|
||||||
unit.pkg
|
By default, if your project contains a build script, cargo scans all files in
|
||||||
)
|
it to determine whether a rebuild is needed. If you don't expect to access the
|
||||||
|
file, specify `rerun-if-changed` in your build script.
|
||||||
|
See https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-changed for more information.";
|
||||||
|
pkg_fingerprint(cx.bcx, &unit.pkg).map_err(|err| {
|
||||||
|
let mut message = format!("failed to determine package fingerprint for build script for {}", unit.pkg);
|
||||||
|
if err.root_cause().is::<io::Error>() {
|
||||||
|
message = format!("{}\n{}", message, IO_ERR_MESSAGE)
|
||||||
|
}
|
||||||
|
err.context(message)
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
)?
|
)?
|
||||||
|
|
|
@ -4639,6 +4639,12 @@ fn build_script_scan_eacces() {
|
||||||
.with_stderr(
|
.with_stderr(
|
||||||
"\
|
"\
|
||||||
[ERROR] failed to determine package fingerprint for build script for foo v0.0.1 ([..]/foo)
|
[ERROR] failed to determine package fingerprint for build script for foo v0.0.1 ([..]/foo)
|
||||||
|
An I/O error happened[..]
|
||||||
|
|
||||||
|
By default[..]
|
||||||
|
it to[..]
|
||||||
|
file[..]
|
||||||
|
See[..]
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
failed to determine the most recently modified file in [..]/foo
|
failed to determine the most recently modified file in [..]/foo
|
||||||
|
|
Loading…
Reference in a new issue