GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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 #3162

New issue
Copy link
New issue
Copy link
Open
Open
Install Rust tools with --locked by default or add a parameter to allow this#3162
Copy link

Description

@mlegner
mlegner
opened on Mar 21, 2024
Issue body actions

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

Reacted by Tim Hutt, JGStew, Markus Hofbauer, Jannik Schäfer, Philipp Niedermayer and Dominic Kempf

Activity

  1. asottile commented on Mar 21, 2024

    @asottile
    asottile
    on Mar 21, 2024
    Member
    More actions

    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

  2. mlegner commented on Mar 21, 2024

    @mlegner
    mlegner
    on Mar 21, 2024
    Author
    More actions

    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
  3. asottile commented on Mar 21, 2024

    @asottile
    asottile
    on Mar 21, 2024
    Member
    More actions

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

  4. mlegner commented on Mar 21, 2024

    @mlegner
    mlegner
    on Mar 21, 2024
    Author
    More actions

    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'.
    
  5. Timmmm commented on Jul 8, 2024

    @Timmmm
    Timmmm
    on Jul 8, 2024
    More actions

    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.

    Reacted by Markus Legner
  6. Terseus
    added a commit that references this issue on Jul 11, 2024

    allow rust hooks to specify arbitrary cargo install parameters

    This issue will close once commit 558793b is merged into the 'main' branch.
    558793b
  7. bbannier commented on Sep 11, 2024

    @bbannier
    bbannier
    on Sep 11, 2024
    More actions

    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.

  8. 0xxon
    added 2 commits that reference this issue on Sep 11, 2024

    Pre-commit - remove spicy-format

    5cc0770

    Pre-commit - remove spicy-format

    6610eac
  9. bbannier
    added a commit that references this issue on Sep 11, 2024

    Bump topiary ecosystem

    c0cfc41
  10. bbannier
    added 3 commits that reference this issue on Oct 8, 2025

    Unbreak building without `--locked` due to prettydiff semver

    2328299

    Unbreak building without `--locked` due to prettydiff semver break

    c680ad9

    Bump spicy-format

    36a53dd
  11. eltos commented on Feb 17, 2026

    @eltos
    eltos
    on Feb 17, 2026 · Hidden as off-topic
    show commentMore actions
  12. j178
    added a commit that references this issue on Feb 18, 2026

    Use `--locked` for Rust `cargo install` commands (#1661)

    bfade9f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.