None
}
+/// Returns String representation of dependency chain for a particular `pkgid`.
+fn describe_path(graph: &Graph<PackageId>, pkgid: &PackageId) -> String {
+ use std::fmt::Write;
+ let dep_path = graph.path_to_top(pkgid);
+ let mut dep_path_desc = format!("package `{}`", dep_path[0]);
+ for dep in dep_path.iter().skip(1) {
+ write!(dep_path_desc,
+ "\n ... which is depended on by `{}`",
+ dep).unwrap();
+ }
+ dep_path_desc
+}
+
fn activation_error(cx: &Context,
registry: &mut Registry,
parent: &Summary,
candidates: &[Candidate],
config: Option<&Config>) -> CargoError {
let graph = cx.graph();
- let describe_path = |pkgid: &PackageId| -> String {
- use std::fmt::Write;
- let dep_path = graph.path_to_top(pkgid);
- let mut dep_path_desc = format!("package `{}`", dep_path[0]);
- for dep in dep_path.iter().skip(1) {
- write!(dep_path_desc,
- "\n ... which is depended on by `{}`",
- dep).unwrap();
- }
- dep_path_desc
- };
if !candidates.is_empty() {
let mut msg = format!("failed to select a version for `{}`.", dep.name());
msg.push_str("\n ... required by ");
- msg.push_str(&describe_path(parent.package_id()));
+ msg.push_str(&describe_path(&graph, parent.package_id()));
msg.push_str("\nversions that meet the requirements `");
msg.push_str(&dep.version_req().to_string());
msg.push_str(link);
msg.push_str("` as well:\n");
}
- msg.push_str(&describe_path(p));
+ msg.push_str(&describe_path(&graph, p));
}
let (features_errors, other_errors): (Vec<_>, Vec<_>) = other_errors.drain(..).partition(|&(_, r)| r.is_missing_features());
for &(p, _) in other_errors.iter() {
msg.push_str("\n\n previously selected ");
- msg.push_str(&describe_path(p));
+ msg.push_str(&describe_path(&graph, p));
}
msg.push_str("\n\nfailed to select a version for `");
dep.source_id(),
versions);
msg.push_str("required by ");
- msg.push_str(&describe_path(parent.package_id()));
+ msg.push_str(&describe_path(&graph, parent.package_id()));
// If we have a path dependency with a locked version, then this may
// indicate that we updated a sub-package and forgot to run `cargo
location searched: {}\n",
dep.name(), dep.source_id());
msg.push_str("required by ");
- msg.push_str(&describe_path(parent.package_id()));
+ msg.push_str(&describe_path(&graph, parent.package_id()));
msg
};
-> CargoResult<()> {
// See if we visited ourselves
if !visited.insert(id) {
- let mut cycle = String::new();
- for package_id in visited.iter() {
- cycle += &format!("\n {}", package_id);
- }
- bail!("cyclic package dependency: package `{}` depends on itself. Cycle (not in order):{}",
- id, cycle);
+ bail!("cyclic package dependency: package `{}` depends on itself. Cycle:\n{}",
+ id, describe_path(&resolve.graph, id));
}
// If we've already checked this node no need to recurse again as we'll
assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr_contains("\
-[ERROR] cyclic package dependency: package `test v0.0.0 ([..])` depends on itself. Cycle (not in order):
- test v0.0.0 ([..][/]foo)
-"));
+[ERROR] cyclic package dependency: package `test v0.0.0 ([..])` depends on itself. Cycle:
+package `test v0.0.0 ([..]foo)`"));
}
#[test]
assert_that(p.cargo("build").arg("-v"),
execs().with_status(101)
- .with_stderr_contains("\
-[ERROR] cyclic package dependency: package `a v0.0.1 ([..]")
- .with_stderr_contains("[..]depends on itself[..]")
- .with_stderr_contains(" foo v0.0.1 ([..][/]foo)")
- .with_stderr_contains(" a v0.0.1 ([..][/]a)"));
-
+ .with_stderr_contains(
+r#"[ERROR] cyclic package dependency: package `a v0.0.1 ([..])` depends on itself. Cycle:
+package `a v0.0.1 ([..]a)`
+ ... which is depended on by `foo v0.0.1 ([..]foo)`[..]"#));
}
#[test]