Skip to content

feat: warn on overlapping output files and unused staging files - #2790

Open
wolfv wants to merge 2 commits into
mainfrom
claude/rattler-build-issue-2730-checks
Open

feat: warn on overlapping output files and unused staging files#2790
wolfv wants to merge 2 commits into
mainfrom
claude/rattler-build-issue-2730-checks

Conversation

@wolfv

@wolfv wolfv commented Sep 1, 2026

Copy link
Copy Markdown
Member

Ref #2730 (see also #2753)

Adds two cross-output consistency checks that run after all outputs are built:

  • Overlapping files — two outputs of the same recipe package the same file, so installing both clobbers it. With staging caches this usually means an output forgot to narrow its files selection.
  • Unused staging files — files from a staging cache were not included in any output that inherits from it (the "silently dropped or silently duplicated" ambiguity from BUG: output with no files: constraint inherits entire staging output as content #2730).

Both are warnings by default; --error-overlapping-files and --error-unused-staging-files turn them into hard errors. Warnings are also recorded on the involved outputs so they appear in build/markdown summaries.

⚠ Outputs 'liba' and 'libb' both package 1 file(s), which will clobber each other on installation:
    - lib/libcore.so
⚠ 1 file(s) from staging cache 'stage' were not included in any of the outputs that inherit from it (liba, libb):
    - include/unused.h

How

create_package now records the prefix-relative files each output selected for packaging (before noarch path remapping) in the build summary. The checks in the new output_checks module compare those sets:

  • Overlap: pairwise within one recipe, on prefix-relative paths — so a noarch and an arch output shipping the same prefix file are caught even though their packaged paths differ. Same-name outputs are never compared (they can't be co-installed); variant repeats of a pair are deduped.
  • Unused: per cache directory (one per staging output + variant selection), against prefix_files from the cache's metadata.json, minus files packaging always drops (CACHEDIR.TAG, .pyo, …). A cache is only judged when all of its inheriting outputs were packaged in the run — a consumer skipped by --skip-existing/--noarch-build-platform or failed under --continue-on-failure leaves usage unknown, so no false errors (verified manually with --skip-existing=local --error-unused-staging-files).

Notes

  • test-data/recipes/staging/multiple-staging-caches.yaml now (correctly) warns: libcore and core-headers genuinely both package include/core.h.
  • Flag plumbing follows --error-prefix-in-binary; py-rattler-build passes the defaults (can be exposed as kwargs later).
  • CLI docs regenerated with rattler_build_docs; prose section added to docs/multiple_output_cache.md.

Tests

  • e2e test_staging_consistency_checks: both warnings fire on a new fixture, and each flag makes the build fail.
  • e2e test_staging_checks_quiet_when_all_files_used: a recipe whose outputs cover the cache and share nothing builds clean under both strict flags.
  • Full workspace tests green except pre-existing test_system_tool (no patchelf in the dev container); all 23 staging e2e tests pass; fmt and clippy clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_016Rj3CRpTRFpCtsnCVdaaQd


Generated by Claude Code

Claude and others added 2 commits September 1, 2026 14:28
After all outputs are built, warn when two outputs of one recipe package the
same file (installing both clobbers it), and when files from a staging cache
were not included in any output that inherits from it. `--error-overlapping-files`
and `--error-unused-staging-files` turn the warnings into hard errors.

Both checks compare the prefix-relative files each output selected for
packaging, recorded in the build summary before noarch path remapping. A cache
is only judged when all of its inheriting outputs were packaged in the run, so
`--skip-existing` or a failed output cannot produce false positives.

Ref #2730

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Rj3CRpTRFpCtsnCVdaaQd
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

Successfully merging this pull request may close these issues.

1 participant