#3278·pre-commit

migrate rust language's addition-dependencies to use cargo install

Author: 2bndy5Created Aug 21, 2024Updated Sep 24, 2025

search you tried in the issue tracker

rust

describe your actual problem

This is following the discussion about allowing cargo features to be used in rust-based hooks (started in #3230 continued in #3235).

The cargo add command has been used since 2018 to add dependencies to a rust-based hook's manifest (Cargo.toml). Sometime since then (probably when 2021 edition was stabalized), cargo features were implemented in the cargo install command. As noted in https://github.com/pre-commit/pre-commit/pull/3235#issuecomment-2299164211, this makes cargo install more suitable for a rust-based hook's additional-dependencies because it actually installs additionally specified dependencies.

[!tip] Using --locked better assures expected install behavior. However, this is not the default for cargo install.

pre-commit --version

3.7.1