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

Need a way to specify toolchain channel for each hook #15

Open
zackw opened this issue Nov 24, 2020 · 5 comments
Open

Need a way to specify toolchain channel for each hook #15

zackw opened this issue Nov 24, 2020 · 5 comments

Comments

@zackw
Copy link

zackw commented Nov 24, 2020

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.

@olexiyb
Copy link

olexiyb commented Nov 26, 2020

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

@danieleades
Copy link

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

@krruzic
Copy link

krruzic commented Oct 9, 2021

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.

@danieleades
Copy link

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.

@zackw
Copy link
Author

zackw commented Oct 9, 2021

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

yes, exactly.

OverkillGuy pushed a commit to OverkillGuy/grepkin that referenced this issue Apr 10, 2022
Formatter should run on nightly Rust, so should clippy the linter.

Unfortunately, the pre-commit hook won't let us specify toolchain[1].
Instead, redefine the hook locally, with the right flags.

[1]: doublify/pre-commit-rust#15 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants