Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Rust tools with --locked by default or add a parameter to allow this #3162

Open
mlegner opened this issue Mar 21, 2024 · 4 comments
Open

Comments

@mlegner
Copy link

mlegner commented Mar 21, 2024

search 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

@asottile
Copy link
Member

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
Copy link
Author

mlegner commented Mar 21, 2024

does cargo not use the lock file if present by default?

No, the lock file is ignored by default.

@asottile
Copy link
Member

hmmmmm I think additional_dependencies: [--locked] will work

@mlegner
Copy link
Author

mlegner commented 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'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants