Skip to content

"cannot specify the --color option with --json" without --color being passed #65558

Closed

Description

Running Servo’s unit tests started failing on CI a couple nightlies ago. A customized CI task to add -j1 shows:

https://tools.taskcluster.net/groups/Pl5QK7YnS3eldtQ6EwR09A/tasks/Pl5QK7YnS3eldtQ6EwR09A/runs/0/logs/public%2Flogs%2Flive.log

   Compiling servo_remutex v0.0.1 (/repo/components/remutex)
     Running `sccache rustc --edition=2018 --crate-name smoke components/remutex/tests/smoke.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -C debuginfo=2 --test -C metadata=5076d3288909fc2b -C extra-filename=-5076d3288909fc2b --out-dir /repo/target/debug/deps -L dependency=/repo/target/debug/deps --extern lazy_static=/repo/target/debug/deps/liblazy_static-30d72531331b6d3e.rlib --extern log=/repo/target/debug/deps/liblog-147e2d153a2e1822.rlib --extern servo_remutex=/repo/target/debug/deps/libservo_remutex-8b018814b17ada98.rlib -C link-args=-fuse-ld=gold -W unused-extern-crates`
error: cannot specify the `--color` option with `--json`

error: could not compile `servo_remutex`.

The error message appears to come from here:

if matches.opt_str("color").is_some() {
early_error(
ErrorOutputType::default(),
"cannot specify the `--color` option with `--json`",
);
}

Reading through the call sites of this function I quickly reach env::args_os() in rustc_driver::main, so I don’t understand how this message could be emitted while --color is not actually present in the command-line arguments given to rustc by Cargo.

I have also not managed to reproduce this outside of the CI environment.

I don’t have an exact regression range, but this started happening a couple days ago which is close to when #65445 landed. This PR updated Cargo, including rust-lang/cargo#7450 whose description mentions using rustc’s JSON output more. I suspect this is what caused the issue to be uncovered, but it looks like the root cause is in rustc’s argument parsing.

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

Metadata

Assignees

No one assigned

    Labels

    A-driverArea: rustc_driver that ties everything together into the `rustc` compilerC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions