Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print target when selects fail to match on toolchain targets #733

Open
thetimmorland opened this issue Aug 5, 2024 · 0 comments
Open

Print target when selects fail to match on toolchain targets #733

thetimmorland opened this issue Aug 5, 2024 · 0 comments

Comments

@thetimmorland
Copy link

thetimmorland commented Aug 5, 2024

When a select expression fails to match on a toolchain target, the error message tells you the name of attribute which failed to match but not the target that attribute was on:

BUILD FAILED
configuring attr `compiler_flags`

The below patch modifies this message to include the target.

diff --git a/app/buck2_configured/src/nodes/calculation.rs b/app/buck2_configured/src/nodes/calculation.rs
index b3e0e9686f..1cee0384f3 100644
--- a/app/buck2_configured/src/nodes/calculation.rs
+++ b/app/buck2_configured/src/nodes/calculation.rs
@@ -723,7 +723,13 @@ async fn gather_deps(
 
     let mut traversal = Traversal::default();
     for a in target_node.attrs(AttrInspectOptions::All) {
-        let configured_attr = a.configure(attr_cfg_ctx)?;
+        let configured_attr = a.configure(attr_cfg_ctx).with_context(|| {
+            format!(
+                "configuring attr `{}` for target `{}`",
+                a.name,
+                target_node.label()
+            )
+        })?;
         configured_attr.traverse(target_node.label().pkg(), &mut traversal)?;
     }
 
diff --git a/app/buck2_node/src/attrs/coerced_attr_full.rs b/app/buck2_node/src/attrs/coerced_attr_full.rs
index b90008c53f..712469a436 100644
--- a/app/buck2_node/src/attrs/coerced_attr_full.rs
+++ b/app/buck2_node/src/attrs/coerced_attr_full.rs
@@ -31,10 +31,7 @@ impl<'a> CoercedAttrFull<'a> {
         Ok(ConfiguredAttrFull {
             name: self.name,
             attr: self.attr,
-            value: self
-                .value
-                .configure(self.attr.coercer(), ctx)
-                .with_context(|| format!("configuring attr `{}`", self.name))?,
+            value: self.value.configure(self.attr.coercer(), ctx)?,
         })
     }
@thetimmorland thetimmorland changed the title Include target when selects fail to match Print target when selects fail to match Aug 5, 2024
@thetimmorland thetimmorland changed the title Print target when selects fail to match Print target when selects fail to match on toolchain targets Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant