cargo-husky is declared under [dependencies] in Cargo.toml:
https://github.com/akinsella/yt-transcript-rs/blob/main/Cargo.toml#L41
cargo-husky = { version = "1.5.0", features = ["precommit-hook", "run-cargo-fmt", "run-cargo-clippy", "run-cargo-check"] }
It is also already declared where it belongs, under [dev-dependencies] at line 49.
Why this is a problem
cargo-husky does all its work in a build script: it walks up from OUT_DIR until it finds a .git directory, then writes hook files into it. That is safe as a dev-dependency, because dev-dependencies of a transitive dependency are never built — only the crate's own developers ever run it, against their own repo.
As a regular dependency it is built in every downstream consumer, so the build script runs during their build, resolves their .git directory, and installs hooks into their repository.
Because default features are not disabled, consumers get the union of the listed features and cargo-husky's defaults (prepush-hook, run-cargo-test, run-for-all) — hence both a pre-commit and a pre-push hook, each running the full four-command suite with --all across the consumer's entire workspace.
The practical effect on an unrelated project is that every commit and every push starts running that project's full test, clippy and fmt suite, under lint settings it never opted into, with no indication of where the hooks came from beyond the generated comment.
Suggested fix
Delete the [dependencies] entry (line 41) and move its feature list onto the existing [dev-dependencies] entry (line 49):
[dev-dependencies]
cargo-husky = { version = "1.5.0", features = ["precommit-hook", "run-cargo-fmt", "run-cargo-clippy", "run-cargo-check"] }
The hooks keep working for contributors to this repo, and consumers stop building cargo-husky at all.
Workaround for consumers
Until a fixed release is published, add to .cargo/config.toml:
[env]
CARGO_HUSKY_DONT_INSTALL_HOOKS = "1"
and delete the already-installed .git/hooks/pre-commit and .git/hooks/pre-push.
Observed on yt-transcript-rs 0.1.8 (current latest on crates.io).
cargo-huskyis declared under[dependencies]inCargo.toml:https://github.com/akinsella/yt-transcript-rs/blob/main/Cargo.toml#L41
It is also already declared where it belongs, under
[dev-dependencies]at line 49.Why this is a problem
cargo-huskydoes all its work in a build script: it walks up fromOUT_DIRuntil it finds a.gitdirectory, then writes hook files into it. That is safe as a dev-dependency, because dev-dependencies of a transitive dependency are never built — only the crate's own developers ever run it, against their own repo.As a regular dependency it is built in every downstream consumer, so the build script runs during their build, resolves their
.gitdirectory, and installs hooks into their repository.Because default features are not disabled, consumers get the union of the listed features and cargo-husky's defaults (
prepush-hook,run-cargo-test,run-for-all) — hence both apre-commitand apre-pushhook, each running the full four-command suite with--allacross the consumer's entire workspace.The practical effect on an unrelated project is that every commit and every push starts running that project's full test, clippy and fmt suite, under lint settings it never opted into, with no indication of where the hooks came from beyond the generated comment.
Suggested fix
Delete the
[dependencies]entry (line 41) and move its feature list onto the existing[dev-dependencies]entry (line 49):The hooks keep working for contributors to this repo, and consumers stop building cargo-husky at all.
Workaround for consumers
Until a fixed release is published, add to
.cargo/config.toml:and delete the already-installed
.git/hooks/pre-commitand.git/hooks/pre-push.Observed on
yt-transcript-rs0.1.8 (current latest on crates.io).