Skip to content

Conversation

@enthropy7
Copy link
Contributor

fixed #2710 by ensuring unstable cargo flags (e.g., -Zbindeps) from [package.metadata.docs.rs] cargo-args are passed to all cargo commands, before it was only rustdoc. Added Metadata::unstable_cargo_flags() to extract -Z* flags and updated load_metadata_from_rustwide() and all cargo invocations (metadata, fetch, generate-lockfile, rustdoc) to accept and forward these flags. This lets crates using unstable features build on docs.rs. change is minimal, backward compatible, and follows existing patterns, covering all cargo commands to prevent failures at any stage. all tests added in 2 commits. 1-st demonstrate how it was before, 2-nd - how it works now (well).

@enthropy7 enthropy7 requested a review from a team as a code owner January 1, 2026 20:09
@github-actions github-actions bot added the S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed label Jan 1, 2026
@enthropy7
Copy link
Contributor Author

r? @syphar take a look please if you have time :>

@syphar
Copy link
Member

syphar commented Jan 4, 2026

r? @syphar take a look please if you have time :>

Already saw it, needed to finish a bigger refactor (#3113).

Also need to check the implications of adding this argument to all commands. Give me a couple of days.

Until then:
the linters fail, you can already fix that. (running just lint locally should suffice)

@enthropy7
Copy link
Contributor Author

r? @syphar take a look please if you have time :>

Already saw it, needed to finish a bigger refactor (#3113).

Also need to check the implications of adding this argument to all commands. Give me a couple of days.

Until then: the linters fail, you can already fix that. (running just lint locally should suffice)

thanks! about link - it’s false detection as i remember, but i will check it again

@syphar
Copy link
Member

syphar commented Jan 4, 2026

thanks! about link - it’s false detection as i remember, but i will check it again

in what way? It's rustfmt failing, so you have to run it locally.

Also check if you're using the latest rust stable.

@enthropy7
Copy link
Contributor Author

thanks! about link - it’s false detection as i remember, but i will check it again

in what way? It's rustfmt failing, so you have to run it locally.

Also check if you're using the latest rust stable.

oh, sorry then, i’m currently working on many projects, something mixed up in my brain. will fix this if a new few hours

@enthropy7 enthropy7 force-pushed the main branch 3 times, most recently from 962dca4 to f2f2850 Compare January 4, 2026 14:03
@syphar
Copy link
Member

syphar commented Jan 9, 2026

starting to look into this

Copy link
Member

@syphar syphar left a comment

Choose a reason for hiding this comment

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

I need to do more research here before we can merge this.

To explain:
we have two ways of running cargo commands here.

  1. "safe" commands are run directly on the docs.rs server.
  2. "unsafe" commands are run inside a docker container

in the code:

  • Command::new is on the host,
  • stuff behind prepare_sandbox or in methods accepting a &Build is sandboxed

All commands where a crate author could run their own code (like in a build script) in any way have to be sandboxed, otherwise it would be possible for one crate author to affect the build output of other crates, so also what's hosted / distributed via docs.rs

For the current commands that are run on the host (generate-lockfile, fetch, etc) we know that there is no way you can affect the host in any way.

What I don't know: Does bindeps or any other unstable cargo feature open up these possibilities? If yes, we need to also sandbox these commands.

I'll try to get someone from the cargo team to provide more insight.

@@ -0,0 +1,12 @@
[package]
Copy link
Member

Choose a reason for hiding this comment

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

this crate should be moved to the "new" location

crates/bin/docs_rs_builder/tests/crates/

@syphar syphar removed their assignment Jan 9, 2026
@syphar
Copy link
Member

syphar commented Jan 9, 2026

just a note: please don't start sandboxing for now, generally sandboxed commands run slower, and we would have to keep the sandbox limits in mind. :)

This commit adds tests that demonstrate the problem: crates using
unstable cargo features like `-Zbindeps` fail to build because the
unstable flags from `cargo-args` are not passed to `cargo metadata`
and `cargo fetch` commands.

- Add test_bindeps_cargo_args_parsing() to verify cargo-args parsing
- Add test_bindeps_separate_args_parsing() for -Z bindeps style
- Add test_bindeps_crate_fails_without_unstable_flags() integration test
  that EXPECTS FAILURE (demonstrates the issue)
- Add test_load_metadata_signature_doesnt_accept_unstable_flags() to document the issue
- Add test crate tests/crates/bindeps-test/ with bindeps configuration

These tests demonstrate the issue:
1. load_metadata_from_rustwide() doesn't accept unstable flags parameter
2. cargo metadata/fetch are called without -Z flags from cargo-args
3. This causes builds to fail for crates using bindeps

See: rust-lang#2710
@enthropy7 enthropy7 force-pushed the main branch 4 times, most recently from 6298fe6 to be755ba Compare January 9, 2026 23:29
This commit fixes issue rust-lang#2710 by ensuring that unstable cargo flags
(e.g., `-Zbindeps`) from `cargo-args` are passed to ALL cargo
commands, not just `cargo rustdoc`.

Changes:
- Add `Metadata::unstable_cargo_flags()` method to extract `-Z*` flags
  from `cargo-args`
- Update `load_metadata_from_rustwide()` to accept `unstable_flags`
  parameter and pass them to `cargo metadata`
- Update `build_local_package()` to read metadata and pass unstable flags
- Update `execute_build()` to pass unstable flags to `cargo metadata`
- Update fallback path (`cargo generate-lockfile`, `cargo fetch`) to
  pass unstable flags
- Remove unused `.peekable()` in `unstable_cargo_flags()` method
- Apply rustfmt formatting
- Update test to expect success (with fix)
@syphar
Copy link
Member

syphar commented Jan 10, 2026

@enthropy7 generally:
when we do a review, it's better when you just add commits in the branch.

Like this I can directly see what exactly changed after the last review.

( for long-running reviews I even recommend not rebasing on main until before the merge).

@enthropy7
Copy link
Contributor Author

@enthropy7 generally: when we do a review, it's better when you just add commits in the branch.

Like this I can directly see what exactly changed after the last review.

( for long-running reviews I even recommend not rebasing on main until before the merge).

ok, thanks, that's just practice i learnt from cargo rules of commit :)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crates using unstable cargo feature bindeps are not buildable in docs.rs

2 participants