GeezerVison is showing github.com — Install Rust tools with `--locked` by default or add a parameter to allow this · Issue #3162 · pre-commit/pre-commit
Install Rust tools with --locked by default or add a parameter to allow this #3162Descriptionsearch you tried in the issue tracker
rust locked
describe your actual problem
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.
pre-commit --version
pre-commit 3.6.2 Reacted by Tim Hutt, JGStew, Markus Hofbauer, Jannik Schäfer, Philipp Niedermayer and Dominic Kempf Activityasottile commented on Mar 21, 2024 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 mlegner commented on Mar 21, 2024
does cargo not use the lock file if present by default?
No, the lock file is ignored by default. Reacted by JGStew and Joël Bourgault asottile commented on Mar 21, 2024 hmmmmm I think additional_dependencies: [--locked] will work mlegner commented on Mar 21, 2024 No, unfortunately this doesn't seem to work as an @* is added automatically:
An unexpected error has occurred: CalledProcessError: command: ('~/.cargo/bin/cargo', 'add', '--locked@*')
return code: 1
stdout: (none)
stderr:
error: unexpected argument '--locked@*' found
tip: a similar argument exists: '--locked'
Usage: cargo add [OPTIONS] <DEP>[@<VERSION>] ...
cargo add [OPTIONS] --path <PATH> ...
cargo add [OPTIONS] --git <URL> ...
For more information, try '--help'.
Timmmm commented on Jul 8, 2024 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. added a commit that references this issue on Jul 11, 2024This issue will close once commit 558793b is merged into the 'main' branch.558793b bbannier commented on 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. eltos commented on Feb 17, 2026
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|