Closed AceofSpades5757 closed 2 years ago
do you have a link to your run? this is supposed to work (I've used rustfmt
myself before)
Yeah, here you go: https://results.pre-commit.ci/run/github/481453952/1651103136.fLOGLt7dR629nADKzzK34A
Is it? They don't have the hook file and the hook repo I found that allowed you to use rustfmt
wouldn't work (this one). I think it was because it required cargo
installed on pre-commit.ci
with the option language: system
set.
I used it with repo: local
before, let me see if I can get that working again (it was mostly just to demonstrate the rust support)
it looks like installing rustfmt
tries to install a nightly rust globally, which isn't supported -- you could perhaps try and review / complete this pre-commit feature which would make that possible: https://github.com/pre-commit/pre-commit/pull/1863
yeah the latest version of rustfmt
requires nightly rustc to build, we only ship stable rustc
if you can figure out how to ship both that'd be acceptable as well -- https://github.com/pre-commit-ci/runner-image -- I don't know quite enough about cargo to make that happen myself unfortunately
Got it, thanks. It should work on stable just fine, so I'll take a look.
oh it looks like we ship rustfmt
as a global component already so it might not need to be installed? https://github.com/pre-commit-ci/runner-image/blob/9e9e4bc58407b77f3103e4c1fbf4632f7d5db415/Dockerfile#L125
If the component is added, then the command would be cargo fmt
, but I'm not sure how to explain that to pre-commit.ci
.
- repo: local
hooks:
- id: cargo-fmt
name: cargo fmt
language: rust
entry: cargo fmt
types: [rust]
that should work (assuming I remembered all the fields while typing a pre-commit config on my phone!)
Close! I changed the entry
to rustfmt
to accept paths and it worked! Thank you very much.
Here's that some piece from my config file. Hope someone else finds this useful.
- repo: local
hooks:
- id: cargo-fmt
name: Rust Formatter
description: "A tool for formatting Rust code according to style guidelines."
language: rust
entry: rustfmt
types: [rust]
While trying to get
rustfmt
to work, I ran into this error. Therustfmt
repo was one I had forked and added a.pre-commit-config.yaml
file to, matching Python'sblack
repo for reference. Although this worked great on my machine, it doesn't seem to work when trying to use withpre-commit.ci
.Any suggestions? I saw some similar issues, but thought they'd be handled once the hook file was added to the repository, and the appropriate changes to the options, like language, be made.
If this is intended to fail, could there be a more clear message as to why the hook failed?
Error Output
Added hook config file
Note: Unsure as to what information would be useful here.