Re-invalidate build.rs when extracted CLI cache is removed#1480
Merged
Conversation
Add rerun-if-changed for the extracted binary path so cargo re-runs build.rs when the cached CLI disappears (cache GC, manual rm, OS reset, switching COPILOT_CLI_EXTRACT_DIR). Without this, cargo replays the saved has_extracted_cli cfg from its build-script output cache even when the file is gone, causing runtime BinaryNotFound failures despite a successful cargo build. Also gate the cfg emission on final_path.is_file() so the cfg is only set when the binary actually exists post-extraction. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Rust SDK build-script cache invalidation for unbundled CLI builds, ensuring Cargo reruns build.rs when the extracted CLI binary cache is removed so runtime resolution stays consistent with build output.
Changes:
- Adds a
rerun-if-changeddirective for the extracted CLI binary path. - Emits
has_extracted_clionly when the expected extracted binary exists after the build-script extraction step.
Show a summary per file
| File | Description |
|---|---|
rust/build.rs |
Updates unbundled CLI extraction invalidation and cfg emission logic. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
SteveSandersonMS
approved these changes
May 28, 2026
SteveSandersonMS
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
bundled-cliis OFF,build.rsdownloads and extracts the Copilot CLI binary to a platform cache directory at build time, then emitscargo:rustc-cfg=has_extracted_cliso the runtime resolver knows where to look.Problem: no
rerun-if-changeddirective watches the extracted binary itself. If the file disappears between builds (cache GC,rm -rf ~/Library/Caches, switchingCOPILOT_CLI_EXTRACT_DIR) and no other watched input changes, cargo treats the build script as up-to-date, replays the cachedhas_extracted_clicfg, and the runtime resolver hitsBinaryNotFounddespite a "successful" build.Fix:
rerun-if-changed=<final_path>pointing at the extracted binary. Cargo's semantics for a missing path are "always rerun" — exactly the right behavior here.rustc-cfg=has_extracted_cliwhenfinal_path.is_file()holds after extraction, making the cfg honest about ground truth.The
bundled-cliON path (embed mode) is unchanged.