You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Install Rust tools with --locked by default or add a parameter to allow this #3162
Many (most?) Rust projects come with lock files that specify the exact versions of dependencies with which they are tested. Sometimes, they don't work with newer versions, which is why Cargo offers the --locked parameter to build with the dependency versions specified in the lock files.
Currently, pre-commit installs Rust tools without the --locked parameter. I suggest to use this parameter by default or offer a way to specify that a hook should be built using that parameter.
does cargo not use the lock file if present by default? I was under the impression that --locked is only necessary to produce an error if it is missing
Yeah this is a bit awkward. I have resorted to using =1.2.3 style dependencies in my Cargo.toml file, but this isn't a full solution because it doesn't lock transitive dependencies.
This issue basically makes it impossible for me to package a linter in a pre-commit hook since to build this linter one has to use locked dependencies, and there is no officially supported way to pull in pre-built binaries, see #1453.
Activity
asottile commentedon Mar 21, 2024
does cargo not use the lock file if present by default? I was under the impression that
--lockedis only necessary to produce an error if it is missingmlegner commentedon Mar 21, 2024
No, the lock file is ignored by default.
asottile commentedon Mar 21, 2024
hmmmmm I think
additional_dependencies: [--locked]will workmlegner commentedon Mar 21, 2024
No, unfortunately this doesn't seem to work as an
@*is added automatically:Timmmm commentedon Jul 8, 2024
Yeah this is a bit awkward. I have resorted to using
=1.2.3style dependencies in myCargo.tomlfile, but this isn't a full solution because it doesn't lock transitive dependencies.allow rust hooks to specify arbitrary cargo install parameters
bbannier commentedon Sep 11, 2024
This issue basically makes it impossible for me to package a linter in a pre-commit hook since to build this linter one has to use locked dependencies, and there is no officially supported way to pull in pre-built binaries, see #1453.
Pre-commit - remove spicy-format
Pre-commit - remove spicy-format
Bump topiary ecosystem
Unbreak building without `--locked` due to prettydiff semver
Unbreak building without `--locked` due to prettydiff semver break
Bump spicy-format
eltos commentedon Feb 17, 2026
Use `--locked` for Rust `cargo install` commands (#1661)