swellaby / rusty-hook

git hook manager, geared toward Rust projects
MIT License
206 stars 11 forks source link

rusty-hook: command not found #105

Closed slondr closed 4 years ago

slondr commented 4 years ago

Environment Details

Description

After following the steps in the readme, any git commit gives the following error message:

Finalizing rusty-hook configuration...
This may take a few seconds...
.git/hooks/pre-commit: line 24: rusty-hook: command not found
Configured hook command failed
pre-commit hook rejected
calebcartwright commented 4 years ago

Thanks for the report @slondr

It sounds like the bin didn't get auto-installed correctly. Could you run the below command from your terminal and share the output?

cargo install rusty-hook
slondr commented 4 years ago

@calebcartwright

    Updating crates.io index
     Ignored package `rusty-hook v0.11.1` is already installed, use --force to override

Running the command with --force did not fix the error

calebcartwright commented 4 years ago

and what about

rusty-hook --version
slondr commented 4 years ago

zsh: command not found: rusty-hook

calebcartwright commented 4 years ago

that'd explain it then. do you have ~/.cargo/bin on your path?

slondr commented 4 years ago

Nope. Should I?

calebcartwright commented 4 years ago

Yes, the rusty-hook bin needs to be on your path. Did you use rustup to install rust on your system?

slondr commented 4 years ago

I believe I did.

Adding .cargo/bin to my path works when I use git via the command line, but doesn't work when I use a git front-end that spawns its own shells (like magit does).

calebcartwright commented 4 years ago

It sounds like there's a rust config/setup issue with your environment. You'll always want to have cargo's bin directory on your path, and IIRC rustup does this as part of your setup (though I think there's an issue with fish)

I'm not familiar with magit, but as long as the shells it spawns have cargo's bin dir available (presumably via some profile or explicit config) then things should work

calebcartwright commented 4 years ago

@slondr Thanks again for reaching out. We've added a note to the readme docs to call out the requirement for having cargo's bin dir on your path, with a pointer to the official install instructions for more information.

There's not really much else we can do on the rusty-hook side, so I'm going to go ahead and close this. Please feel free to reach out though if you have any questions!

https://www.rust-lang.org/tools/install

Configuring the PATH environment variable

In the Rust development environment, all tools are installed to the ~/.cargo/bin directory, and this is where you will find the Rust toolchain, including rustc, cargo, and rustup.

Accordingly, it is customary for Rust developers to include this directory in their PATH environment variable. During installation rustup will attempt to configure the PATH. Because of differences between platforms, command shells, and bugs in rustup, the modifications to PATH may not take effect until the console is restarted, or the user is logged out, or it may not succeed at all.

brizzbuzz commented 3 years ago

Hey just wanna follow up for anyone who ends up here, this was a problem for me, I installed rust using ASDF so I'd imagine the problem lies in the way that ASDF sets up the cargo shim vs how rusty-hook expects to find it... not gonna reopen cuz it seems like a me problem 😄 but hopefully this helps someone!