pre-commit-rust icon indicating copy to clipboard operation
pre-commit-rust copied to clipboard

Need a way to specify toolchain channel for each hook

Open zackw opened this issue 5 years ago • 5 comments

I'm tinkering with a project, right now, which compiles fine with stable rust, but its rustfmt configuration uses a whole bunch of options that are only available with nightly rustfmt. I don't want to switch my default toolchain to nightly just for the sake of this project. It would be nice if it were possible to specify, in .pre-commit-config.yaml for this project, that the fmt hook should run cargo +nightly fmt instead of cargo fmt.

This doesn't appear to be possible with the args array because that's inserted too late on the command line, e.g.

  hooks:
    - id: fmt
      args: ["+nightly"]

gives an error message about there not being any file named +nightly.

zackw avatar Nov 24 '20 20:11 zackw

the hooks using default toolchain enabled on your system, If you want to check your code against different platforms it will be better to do using Github Actions for example

https://github.com/logannc/fuzzywuzzy-rs/blob/master/.github/workflows/clippy.yml

olexiyb avatar Nov 26 '20 07:11 olexiyb

that's a shame this isn't supported. i'm using nightly clippy and nightly rustfmt, and stable otherwise.

danieleades avatar Jun 12 '21 09:06 danieleades

Adding this is really simple, just fork the repo and change the entry: lines in hooks.yaml to say cargo +nightly ... instead. I've done it on my fork.

krruzic avatar Oct 09 '21 08:10 krruzic

Adding this is really simple, just fork the repo and change the entry: lines in hooks.yaml to say cargo +nightly ... instead. I've done it on my fork.

i think the issue is wanting to use different toolchains for different checks.

danieleades avatar Oct 09 '21 08:10 danieleades

i think the issue is wanting to use different toolchains for different checks.

yes, exactly.

zackw avatar Oct 09 '21 17:10 zackw