Skip to content

fix: skip CLI download in build.rs when DOCS_RS env var is set#1660

Merged
edburns merged 6 commits into
mainfrom
copilot/fix-docs-rs-error
Jun 17, 2026
Merged

fix: skip CLI download in build.rs when DOCS_RS env var is set#1660
edburns merged 6 commits into
mainfrom
copilot/fix-docs-rs-error

Conversation

Copilot AI commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

docs.rs builds fail because build.rs attempts to download the Copilot CLI binary in a network-restricted sandbox. The all-features = true docs.rs metadata enables bundled-cli, triggering the download path.

  • Detect the DOCS_RS environment variable (set automatically by docs.rs) and early-return from build.rs, skipping the download/bundle/cache mechanism — same behavior as the existing COPILOT_SKIP_CLI_DOWNLOAD escape hatch
  • Register DOCS_RS with cargo:rerun-if-env-changed for correct incremental rebuild invalidation

Neither has_bundled_cli nor has_extracted_cli cfg flags are emitted in this mode, which is fine — rustdoc only needs type signatures and doc comments, not a working CLI binary.

Fixes #1659

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
Copilot AI requested a review from edburns June 13, 2026 14:29

@edburns edburns left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stephentoub reviewed and approved.

@edburns edburns marked this pull request as ready for review June 17, 2026 17:24
@edburns edburns requested a review from a team as a code owner June 17, 2026 17:24
Copilot AI review requested due to automatic review settings June 17, 2026 17:24
@edburns edburns merged commit 9b3dadf into main Jun 17, 2026
23 checks passed
@edburns edburns deleted the copilot/fix-docs-rs-error branch June 17, 2026 17:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_RS handling in rust/build.rs to skip CLI download/bundle/cache work during docs.rs builds.
  • Add cargo:rerun-if-env-changed=DOCS_RS so 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 use cargo::rustc-check-cfg, which Cargo won’t recognize as a valid instruction. That means the has_bundled_cli / has_extracted_cli cfgs may not be registered via rustc-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

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.

Fix error in docs.rs: docs.rs failed to build github-copilot-sdk-1.0.1

3 participants