fix: skip CLI download in build.rs when DOCS_RS env var is set#1660
Merged
Conversation
docs.rs builds in a sandboxed environment without network access. The build.rs script was failing because it tried to download the Copilot CLI binary. Detect the DOCS_RS environment variable (set automatically by docs.rs) and skip the download, similar to the existing COPILOT_SKIP_CLI_DOWNLOAD escape hatch. Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix error in docs.rs for github-copilot-sdk
fix: skip CLI download in build.rs when DOCS_RS env var is set
Jun 13, 2026
edburns
approved these changes
Jun 17, 2026
edburns
left a comment
Collaborator
There was a problem hiding this comment.
@stephentoub reviewed and approved.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses Rust crate documentation builds on docs.rs failing due to build.rs attempting to download the Copilot CLI binary in a network-restricted environment, by detecting docs.rs’ DOCS_RS environment variable and short-circuiting the download/bundling path.
Changes:
- Add
DOCS_RShandling inrust/build.rsto skip CLI download/bundle/cache work during docs.rs builds. - Add
cargo:rerun-if-env-changed=DOCS_RSso Cargo invalidates build-script output correctly when the env var changes.
Show a summary per file
| File | Description |
|---|---|
| rust/build.rs | Skips CLI download/bundle/cache when DOCS_RS is set and registers env var for rebuild invalidation. |
Copilot's findings
Comments suppressed due to low confidence (1)
rust/build.rs:12
- The build script directive prefix is
cargo:..., but these two lines usecargo::rustc-check-cfg, which Cargo won’t recognize as a valid instruction. That means thehas_bundled_cli/has_extracted_clicfgs may not be registered viarustc-check-cfg, defeating the intent of these lines.
println!("cargo:rerun-if-env-changed=DOCS_RS");
println!("cargo:rerun-if-env-changed=COPILOT_SKIP_CLI_DOWNLOAD");
println!("cargo:rerun-if-env-changed=COPILOT_CLI_EXTRACT_DIR");
println!("cargo:rerun-if-env-changed=BUNDLED_CLI_CACHE_DIR");
println!("cargo::rustc-check-cfg=cfg(has_bundled_cli)");
- Files reviewed: 1/1 changed files
- Comments generated: 0
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.
docs.rs builds fail because
build.rsattempts to download the Copilot CLI binary in a network-restricted sandbox. Theall-features = truedocs.rs metadata enablesbundled-cli, triggering the download path.DOCS_RSenvironment variable (set automatically by docs.rs) and early-return frombuild.rs, skipping the download/bundle/cache mechanism — same behavior as the existingCOPILOT_SKIP_CLI_DOWNLOADescape hatchDOCS_RSwithcargo:rerun-if-env-changedfor correct incremental rebuild invalidationNeither
has_bundled_clinorhas_extracted_clicfg flags are emitted in this mode, which is fine — rustdoc only needs type signatures and doc comments, not a working CLI binary.Fixes #1659