-
Notifications
You must be signed in to change notification settings - Fork 137
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
rustfmt
and clippy
fail with "No such file or directory"
#126
Comments
This solved it for me. Clearly is a hack but I haven't yet look how we can fix this in pre-commit-hooks.nix.
The problem was that |
Could someone open a PR? |
I think what needs to happen here is you need to actually run in an environment that has rustc, cargo, clippy and all the other stuff in the same environment, so it gets kinda tricky. |
Hey folks, I tried to fix this with #156. I've lightly tested it and it does seem to fix the issues described here. Let me know if there's anything I missed. Thanks! |
@winterqt This still is b0rken for me. Requesting to re-open this ticket. I have created a minimal reproducible example at github.com/m1-s/pre-commit-hooks-nix-clippy. When executing |
Ah, I see. Wonder why it's behaving differently in that context -- it's in PATH either way, so that's... weird. I'll take a look at this soon, in the meantime I do agree that this ticket should be reopened. |
@m1-s Your diff --git a/modules/hooks.nix b/modules/hooks.nix
index b97badb..d55ceb5 100644
--- a/modules/hooks.nix
+++ b/modules/hooks.nix
@@ -313,7 +313,7 @@ in
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/cargo-fmt \
- --prefix PATH : ${lib.makeBinPath [ tools.cargo ]}
+ --prefix PATH : ${lib.makeBinPath [ tools.cargo tools.rustfmt ]}
'';
};
in Going back to the first issue, it seems like... well, nobody, has tested the check aspects of this with a project that has dependencies. We obviously need to have a way to download these dependencies into the build directory to be able to check them, which these hooks currently don't provide. I have an idea that involves using |
Thanks for the patch, @winterqt! I can confirm that it fixed the |
@winterqt I cant speak for @domenkozar but I would love to see a PR that fixes clippy. |
cachix/git-hooks.nix#126 reduces the usefulness of the hook. I would like to reintroduce this check once that upstream issue has been resolved.
* Replace `naersk` with `crane` to cache Nix-built dependencies * Remove `cargo check` pre-commit hook cachix/git-hooks.nix#126 reduces the usefulness of the hook. I would like to reintroduce this check once that upstream issue has been resolved. * Update Nix flake sources * Update Cargo dependencies ```shell cargo update ``` * Replacing single-character string with char * Add `packages.ripsecrets` * Perform Nix flake build and check in same step
Somehow it emit this error ``` `cargo metadata` exited with an error: error: rustup could not choose a version of cargo to run, because one wasn't specified explicitly, and no default is configured. help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain. ``` cachix/git-hooks.nix#126
Steps to reproduce:
With the following
flake.nix
:And executing the following commands to create a simple rust project:
You get the following errors in the log:
Even without overriding the
entry
attribute ofclippy
andrustfmt
, I still get the same error.The text was updated successfully, but these errors were encountered: