Skip to content

fix(build): read CARGO_MANIFEST_DIR at build-script run time (shared target dirs) - #11330

Merged
proggeramlug merged 2 commits into
mainfrom
fix/perry-build-script-runtime-manifest-dir
Sep 25, 2026
Merged

proggeramlug merged 2 commits into
mainfrom
fix/perry-build-script-runtime-manifest-dir

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

crates/perry/build/android_template.rs (added with the bundled Android Gradle template, #11276) resolves the template via env!("CARGO_MANIFEST_DIR"), which bakes the path in when the build script is compiled. Cargo reuses a compiled build script across checkouts that share a target directory, so the baked path points at whichever checkout compiled it. Once that worktree is deleted, every later build panics:

thread 'main' panicked at crates/perry/build.rs:5:30:
failed to embed Android Gradle template
  cargo:rerun-if-changed=/Users/…/wt-<deleted>/crates/perry/../perry-ui-android/template

This bit the merge queue three times on a shared target dir. Fix: read CARGO_MANIFEST_DIR from the environment at run time, where cargo sets it for the package being built. Behaviour on a fresh checkout is unchanged. cargo check -p perry is clean.

Summary by CodeRabbit

  • Bug Fixes
    • Android builds now locate the template using the manifest directory available at build time, avoiding failures when a previously compiled build script is reused after the original checkout is removed.

Ralph Küpper added 2 commits September 25, 2026 16:02
crates/perry/build/android_template.rs used env!("CARGO_MANIFEST_DIR"),
which bakes the path in when the build script is compiled. Cargo reuses a
compiled build script across checkouts that share a target dir, so the
baked path points at whichever checkout compiled it; once that worktree
is deleted every later build panics at build.rs:5 (read_dir on a missing
directory). Read the variable at run time, where cargo sets it for the
package being built.
@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: b79436f9-aa61-4023-ae90-c7287f7e5e21

📥 Commits

Reviewing files that changed from the base of the PR and between 3c50eba and 8f93ff3.

📒 Files selected for processing (2)
  • changelog.d/11330-build-script-runtime-manifest-dir.md
  • crates/perry/build/android_template.rs

Included review availability: Your plan provides up to 8 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The Android build script now reads CARGO_MANIFEST_DIR at runtime to locate the Android template. A changelog entry describes the change and the reported failure after Cargo reused a compiled build script when the original checkout was deleted.

Changes

Android template path resolution

Layer / File(s) Summary
Runtime manifest lookup
crates/perry/build/android_template.rs, changelog.d/11330-build-script-runtime-manifest-dir.md
emit reads CARGO_MANIFEST_DIR at runtime and uses it to construct the Android template path. The changelog records the change and reported failure.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 8f93f

The build script now looks up the template using the runtime manifest directory. No actionable merge risk remains; the change is ready for normal checks.

Architecture Summary

Architecture risk: 🔵 Low · up to 8f93f

The change affects 2 systems.

Changed systems: changelog.d, crates

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — changelog.d (service) was modified; 1 changed file maps to changed impact.
  • observed — crates (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in changelog.d/11330-build-script-runtime-manifest-dir.md: Adds a changelog entry describing the CARGO_MANIFEST_DIR change from compile-time embedding to run-time reading and the reported reused-build-script failure.
  • observed — Modified behavior in crates/perry/build/android_template.rs: emit replaces compile-time env! path lookup with runtime env::var_os("CARGO_MANIFEST_DIR") lookup, expecting Cargo to provide the variable before constructing the template path.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, the fix, and one verification command. However, it omits the required Summary, Changes, Related issue, Test plan, and Checklist sections, and it does not state wh… Rewrite the description using the repository template. Add the required section headings, summarize the concrete changes, specify a related issue or write "n/a", list the complete test plan and results, and complete the checklist items. Kee…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: reading CARGO_MANIFEST_DIR at build-script run time to support shared target directories.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, the fix, and one verification command. However, it omits the required Summary, Changes, Related issue, Test plan, and Checklist sections, and it does not state whether the standalone issue or checklist items apply.

Resolution

Rewrite the description using the repository template. Add the required section headings, summarize the concrete changes, specify a related issue or write "n/a", list the complete test plan and results, and complete the checklist items. Keep the existing failure scenario and fix rationale.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proggeramlug
proggeramlug merged commit 1040c5b into main Sep 25, 2026
53 of 55 checks passed
@proggeramlug
proggeramlug deleted the fix/perry-build-script-runtime-manifest-dir branch September 25, 2026 16:29
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