Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo-make not respecting toolchain #1068

Open
wmmc88 opened this issue Apr 10, 2024 · 1 comment
Open

cargo-make not respecting toolchain #1068

wmmc88 opened this issue Apr 10, 2024 · 1 comment
Assignees

Comments

@wmmc88
Copy link
Contributor

wmmc88 commented Apr 10, 2024

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:

  1. install-rustfmt task does not take into account what toolchain is being used. If rust-fmt is only installed for stable, and you are running with nightly, install-rustfmt will not try to install the component for the nightly toolchain.
  2. Since 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 when cargo-make executes Execute Command: "rustup" "run" "nightly" "cargo" "fmt", it has different behaviour that invoking the command (rustup run nightly cargo fmt) directly.

To Reproduce

[tasks.fmt-version]
dependencies = ["install-rustfmt"]
toolchain = "nightly"
command = "cargo"
args = ["fmt", "--version"]
> rustup uninstall nightly
> rustup install nightly --profile minimal

> cargo make fmt-version
cargo-make] INFO - cargo make 0.37.11
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Project: cargo-make
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: fmt-test
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
[cargo-make] INFO - Execute Command: "rustup" "run" "nightly" "cargo" "fmt" "--version"
rustfmt 1.7.0-stable (7cf61ebd 2024-03-27)
[cargo-make] INFO - Build Done in 6.10 seconds.

> rustup run nightly cargo fmt --version  
error: 'cargo-fmt.exe' is not installed for the toolchain 'nightly-x86_64-pc-windows-msvc'.
To install, run `rustup component add  --toolchain {toolchain}rustfmt`

The above snipping shows both problems. install-rustup did not install the nightly version of rustfmt, and cargo-make is for some reason behaving different from manually running the command (ie. its using stable rustfmt instead of erroring).

@sagiegurari
Copy link
Owner

@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)

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

No branches or pull requests

2 participants