xiaohongshu
xiaohongshu
buck2-build-troubleshoot
Debugs Buck2 build failures systematically by analyzing error logs, checking common issues (cache, visibility, cycles), and suggesting fixes. Use when builds fail, tests won't run, or Buck2 reports errors.
Full skill instructions
This skill provides systematic debugging for Buck2 build failures. It analyzes error logs, identifies common issues, and suggests concrete fixes. Instead of manually parsing verbose build output, use the build doctor script to diagnose problems quickly.
Use this skill when:
This skill provides:
scripts/build_doctor.py - Automated build diagnosticsreferences/common_errors.md - Error patterns and solutionsWhen a build fails:
# Run the build doctor
python3 scripts/build_doctor.py
# Or analyze specific target
python3 scripts/build_doctor.py //src/tools:mytool
# Verbose analysis
python3 scripts/build_doctor.py --verbose //src/tools:mytool
The script will:
Rust compilation failure:
Error: rustc failed with exit code 1
Diagnosis:
# See full error
python3 scripts/build_doctor.py --show-logs //target
# Check source files
buck2 query "//target" --output-attribute srcs
# Verify dependencies
buck2 query "deps('//target', 1)"
Common fixes:
Missing dependency:
Error: unresolved import `foo::bar`
Fix:
# Add to BUILD file deps:
deps = [
"//path/to:foo",
"third-party//crate:crate",
]
Circular dependency:
Error: cycle detected in dependency graph
Diagnosis:
# Find the cycle
python3 scripts/build_doctor.py --check-cycles //src/...
# Investigate specific path
buck2 query "allpaths('//target/a', '//target/b')"
buck2 query "allpaths('//target/b', '//target/a')"
Fix: Break the cycle by:
Cannot access target:
Error: //src/app:app cannot depend on //src/lib:internal (not visible)
Diagnosis:
# Check visibility settings
buck2 query "//src/lib:internal" --output-attribute visibility
# See who can access it
python3 scripts/build_doctor.py --check-visibility //src/lib:internal
Fix:
# In BUILD file, update visibility:
depot.rust_library(
name = "internal",
visibility = [
"//src/app/...", # Allow src/app access
# or
"PUBLIC", # Allow everyone
],
)
Undefined reference:
Error: undefined reference to `symbol`
Common causes:
Fix:
# Check all dependencies are present
buck2 query "deps('//target', 1)" --output-attribute deps
# For C++, check link order in BUILD
Tests won't run:
Error: No tests found
Diagnosis:
# Verify test target exists
buck2 targets //path:test
# Check test is properly defined
buck2 query "//path:test" --output-attribute buck.type
Fix:
# Ensure BUILD has test target:
depot.rust_test(
name = "test",
srcs = glob(["src/**/*.rs"]),
)
# Recent failures
buck2 log what-failed
# Or use build doctor
python3 scripts/build_doctor.py
# Full error output
buck2 log last
# Specific target
buck2 build //target -v 2 # Verbose mode
# Run automated checks
python3 scripts/build_doctor.py --all-checks //target
This checks:
# Inspect BUILD file
buck2 query "//target" --json | jq
# Check dependencies
buck2 query "deps('//target', 1)"
# Verify source files exist
buck2 query "//target" --output-attribute srcs
# Build single target
buck2 build //target
# Build with fresh cache
buck2 clean && buck2 build //target
# Skip cache
buck2 build //target --no-remote-cache
# Analyze last failure
python3 scripts/build_doctor.py
# Specific target
python3 scripts/build_doctor.py //src/tools:mytool
# Multiple targets
python3 scripts/build_doctor.py //src/tools:tool1 //src/lib:lib2
# Check cache issues
python3 scripts/build_doctor.py --check-cache
# Check visibility
python3 scripts/build_doctor.py --check-visibility //target
# Check for cycles
python3 scripts/build_doctor.py --check-cycles //src/...
# Run all checks
python3 scripts/build_doctor.py --all-checks //target
# Verbose output
python3 scripts/build_doctor.py --verbose //target
# Show build logs
python3 scripts/build_doctor.py --show-logs //target
# JSON output for scripting
python3 scripts/build_doctor.py --json //target
Error:
Error: No targets found matching //src/tools:missing
Causes:
Fix:
# List available targets
buck2 targets //src/tools:
# Check BUILD file exists
ls -la src/tools/BUILD
# Search for target
buck2 targets //... | grep missing
Error:
Warning: glob(["src/**/*.rs"]) matched no files
Causes:
Fix:
# Check directory structure
ls -la src/
# Verify glob pattern
# For Rust binary: src/main.rs
# For Rust library: src/lib.rs
Error (Rust):
Error: cannot find module `foo` in crate root
Fix:
mod foo; in lib.rs/main.rsError:
Error: feature `foo` is required
Fix:
# Add to BUILD file:
deps = [
"third-party//crate:crate[foo]", # Enable feature
]
Error:
Error: output directory already in use
Causes:
Fix:
# Kill buck daemon
buck2 kill
# Clean and rebuild
buck2 clean
buck2 build //target
Symptoms:
Diagnosis:
# Disable cache and test
buck2 build --no-remote-cache //target
# Check cache configuration
buck2 audit config cache
Fix:
# Clear local cache
buck2 clean
# For persistent issues, check .buckconfig
cat .buckconfig | grep -A5 cache
Symptoms:
Diagnosis:
# Build locally only
buck2 build --no-remote-execution //target
# Check platform configuration
buck2 audit config re
Fix:
Symptoms:
Diagnosis:
# Check what changed
buck2 explain //target
# Verify target determinism
buck2 build //target
buck2 build //target # Should be cached
Fix:
# Find what changed
jj diff --stat | cut -f2 | while read file; do
buck2 query "owner('$file')"
done | while read target; do
python3 scripts/build_doctor.py $target
done
# In CI pipeline
if ! buck2 build @targets; then
python3 scripts/build_doctor.py --json > diagnosis.json
cat diagnosis.json
exit 1
fi
# Diagnose failures in changed targets
TARGETS=$(buck2 run root//buck/tools/quicktd -- '@-' '@' //src/...)
buck2 build @$TARGETS || {
python3 scripts/build_doctor.py --show-logs
}
# What failed recently
buck2 log what-failed
# Show last build log
buck2 log last
# Build with verbose output
buck2 build //target -v 2
# Clean everything
buck2 clean
# Kill buck daemon
buck2 kill
# Explain why rebuilding
buck2 explain //target
# 1. Clean build
buck2 clean && buck2 build //target
# 2. Kill daemon and retry
buck2 kill && buck2 build //target
# 3. Skip cache
buck2 build --no-remote-cache //target
# 4. Verbose output
buck2 build //target -v 2 2>&1 | tee build.log
# 5. Ignore broken targets during testing
buck2 test //... --keep-going
When builds fail, check:
buck2 targets //path:)buck2 clean)buck2 kill)buck2 cleanjj log to see what changedIf stuck after trying these steps:
buck2 build //target -v 2 2>&1 > error.logbuck2 query //target --jsonxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience