Skip to content

Conversation

@Timmmm
Copy link
Contributor

@Timmmm Timmmm commented Dec 12, 2025

This adds a flag that records whether any work was actually done during a build (i.e. it is false for no-change builds). Then for 'manifest' commands, it suppresses some console output if the build was unchanged.

This means that after the first time you run a cargo script and it's all cached, you only see output from the actual command; nothing from cargo (assuming your code has no warnings).

Fixes #16388

Testing

  1. Create this script (if I add any dependencies it gives me grief about mismatched rustc versions or something but we don't need any to test this fortunately):
#!/usr/bin/env -S /path/to/cargo/target/debug/cargo -Zscript
---
[package]
edition = "2024"
[dependencies]
---

fn main() {
    println!("Hello");
}
  1. Build cargo with nightly:
cargo +nightly build
  1. Run the script once. You should see some compilation output messages from Cargo.
  2. Run it again. This time you should only see Hello.

@rustbot
Copy link
Collaborator

rustbot commented Dec 12, 2025

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-build-execution Area: anything dealing with executing the compiler A-cli Area: Command-line interface, option parsing, etc. A-configuration Area: cargo config files and env vars A-console-output Area: Terminal output, colors, progress bar, etc. A-git Area: anything dealing with git A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. A-interacts-with-crates.io Area: interaction with registries Command-info Command-run S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 12, 2025
@Timmmm
Copy link
Contributor Author

Timmmm commented Dec 12, 2025

Note I wasn't exactly sure what the significance of Exec::Manifest is. I couldn't see any comments and it seems to be used for cargo script and some other stuff, but I'm not sure exactly what. Also I don't know what that xtask-bump-check is but I guess this probably doesn't affect it.

This adds a flag that records whether any work was actually done during a build (i.e. it is false for no-change builds). Then for 'manifest' commands, it suppresses some console output if the build was unchanged.

This means that after the first time you run a `cargo script` and it's all cached, you only see output from the actual command; nothing from cargo (assuming your code has no warnings).
@Timmmm Timmmm force-pushed the user/timh/cargo_script_output branch from 736339b to 298846a Compare December 12, 2025 22:30
@epage
Copy link
Contributor

epage commented Dec 12, 2025

Note that our contrib docs discourage PRs until the issue has been accepted by the Cargo team

Going to close for now until something is decided. We can always re-open if this PR is aligned with the agreed-to direction.

@epage epage closed this Dec 12, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-build-execution Area: anything dealing with executing the compiler A-cli Area: Command-line interface, option parsing, etc. A-configuration Area: cargo config files and env vars A-console-output Area: Terminal output, colors, progress bar, etc. A-git Area: anything dealing with git A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. A-interacts-with-crates.io Area: interaction with registries Command-info Command-run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cargo script should only output messages from the script for no-change builds

4 participants