Open wmmc88 opened 7 months ago
@wmmc88 rustfmt tasks are a mess! it has to do with the history of it which rustfmt changed the way you install rustfmt few years back and started to have a nightly and non nightly ways and all that. it was a huge mess! i had a workaround for nightly or stables, with rustup or with cargo install or with install from git. at the end, even that broke due to changes in rustfmt and i left this:
[tasks.install-rustfmt]
description = "Installs cargo rustfmt plugin."
category = "Development"
env.CFG_RELEASE = { value = "${CARGO_MAKE_RUST_VERSION}", condition = { env_not_set = [
"CFG_RELEASE",
] } }
env.CFG_RELEASE_CHANNEL = { value = "${CARGO_MAKE_RUST_CHANNEL}", condition = { env_not_set = [
"CFG_RELEASE_CHANNEL",
] } }
install_crate = { crate_name = "rustfmt-nightly", rustup_component_name = "rustfmt", binary = "rustfmt", test_arg = "--help" }
which is not amazing either. if you want to PR the way rustfmt is installed in a way that it supports the current toolchain correctly, i would love a PR for it. i stopped chasing them. the main goal is having it work correctly in CI flow when running for example in github actions each time with different rust toolchain (even this repo tests on stable, beta and nightly) without it breaking and working for all (right now i disabled it due to the installation issues and only use it in my dev machine where it works ok since i'm always on nightly)
Describe The Bug
I'll preface this by saying that this issue is not blocking me in any way right now, but I noticed it while debugging some other issues I had so I'm reporting it now.
There's actually two issues I see here:
install-rustfmt
task does not take into account what toolchain is being used. Ifrust-fmt
is only installed forstable
, and you are running withnightly
,install-rustfmt
will not try to install the component for the nightly toolchain.nightly
rustfmt
is not installed, I would expect that when cargo make executes something requiring it, it should fail. Instead,cargo-make
defaults to using the stable version instead. I am unsure why whencargo-make
executesExecute Command: "rustup" "run" "nightly" "cargo" "fmt"
, it has different behaviour that invoking the command (rustup run nightly cargo fmt
) directly.To Reproduce
The above snipping shows both problems.
install-rustup
did not install the nightly version ofrustfmt
, andcargo-make
is for some reason behaving different from manually running the command (ie. its using stable rustfmt instead of erroring).