#2740·prek

Rust hooks never use system versions that are not installed with `rustup`

Author: ilovelinuxCreated Sep 19, 2026Updated Sep 19, 2026

Before submitting

  • I have searched the issue list for similar bug reports.

Summary

When

  • rustc 1.95.0 is installed as a standalone package. Installation is not managed by rustup.
  • I set language_version preference to system.

I expect

  • that prek uses system version.

As stated in https://prek.j178.dev/reference/configuration/#language_version:

A “system” toolchain is any toolchain discovered outside prek's managed store, including one installed by an operating-system package manager or version manager.

Instead

  • prek uses rustup to check for Rust availability.
  • rustup doesn't find OS's Rust binary.
  • prek downloads a new toolchain through rustup.

Extra:

  • Since rustup is using a different version (1.98.1) than the one available for my OS(1.95.0), I often hit errors because of build caches created with different versions.

Platform

Linux 7.2.5 x86_64 GNU/Linux

Version (current: 0.5.3)

prek 0.5.2

.pre-commit-config.yaml

yaml
default_language_version:
  rust:
    request: ">=1.95"
    preference: "system"
repos:
- repo: local
  hooks:
  - id: test-rust-version
    name: test-rust-version
    language: rust
    entry: rustc --version
    types: [rust]
    pass_filenames: false
  - id: test-rust-path
    name: test-rust-path
    language: rust
    entry: which rustc
    types: [rust]
    pass_filenames: false
  - id: test-cargo-version
    name: test-cargo-version
    language: rust
    entry: cargo --version
    types: [rust]
    pass_filenames: false
  - id: test-cargo-path
    name: test-cargo-path
    language: rust
    entry: which cargo
    types: [rust]
    pass_filenames: false
  - id: test-local-version
    name: test-local-version
    language: system
    entry: |-
      rustc --version;
      which rustc;
      cargo --version;
      which cargo
    shell: sh
    pass_filenames: false

Log file

$ prek run --all-files -vvv
2026-09-19T19:35:12.680021Z DEBUG prek: 0.5.2
2026-09-19T19:35:12.680036Z DEBUG Args: ["prek", "run", "--all-files", "-vvv"]
2026-09-19T19:35:12.681355Z TRACE root: close time.busy=1.30ms time.idle=1.43µs
2026-09-19T19:35:12.681388Z DEBUG Git root: /tmp/test
2026-09-19T19:35:12.681408Z DEBUG Found workspace root at `/tmp/test`
2026-09-19T19:35:12.681416Z TRACE Include selectors: ``
2026-09-19T19:35:12.681422Z TRACE Skip selectors: ``
2026-09-19T19:35:12.681453Z DEBUG discover{root="/tmp/test" config=None refresh=false}: Performing fresh workspace discovery
2026-09-19T19:35:12.681471Z TRACE discover{root="/tmp/test" config=None refresh=false}:list_submodules{git_root="/tmp/test"}: close time.busy=1.96µs time.idle=560ns
2026-09-19T19:35:12.682374Z DEBUG Loading project configuration path=.pre-commit-config.yaml
2026-09-19T19:35:12.683914Z TRACE discover{root="/tmp/test" config=None refresh=false}: close time.busy=2.48ms time.idle=934ns
2026-09-19T19:35:12.684049Z TRACE Checking lock resource="store" path=/home/user/.cache/prek/.lock
2026-09-19T19:35:12.684083Z DEBUG Acquired lock resource="store"
2026-09-19T19:35:12.684268Z TRACE Released lock path=/home/user/.cache/prek/.lock
2026-09-19T19:35:12.684289Z DEBUG Hooks going to run: ["test-rust-version", "test-rust-path", "test-cargo-version", "test-cargo-path", "test-local-version"]
2026-09-19T19:35:12.684331Z TRACE ls_files{cwd="/tmp/test"}: Executing `cd /tmp/test && /nix/store/msr1v91ybfw6j12rs5mfl8ghb2rqsnsr-git-2.55.0/bin/git -c core.useBuiltinFSMonitor=false --literal-pathspecs ls-files -z -- /tmp/test`
2026-09-19T19:35:12.685804Z TRACE ls_files{cwd="/tmp/test"}: close time.busy=237µs time.idle=1.25ms
2026-09-19T19:35:12.685837Z DEBUG All files in the workspace: 2
2026-09-19T19:35:12.686253Z TRACE Checking lock resource="store" path=/home/user/.cache/prek/.lock
2026-09-19T19:35:12.686276Z DEBUG Acquired lock resource="store"
2026-09-19T19:35:12.688467Z TRACE Checking lock resource="rustup" path=/home/user/.cache/prek/tools/rustup/.lock
2026-09-19T19:35:12.688501Z DEBUG Acquired lock resource="rustup"
2026-09-19T19:35:12.688800Z DEBUG Downloading url=https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init temp_dir="/home/user/.cache/prek/scratch/.tmp8ujOmE"
2026-09-19T19:35:18.943838Z DEBUG Installing rustup path=/home/user/.cache/prek/tools/rustup/rustup
2026-09-19T19:35:18.944100Z TRACE Released lock path=/home/user/.cache/prek/tools/rustup/.lock
2026-09-19T19:35:18.944315Z TRACE Checking lock resource="rustup" path=/home/user/.cache/prek/tools/rustup/.lock
2026-09-19T19:35:18.944335Z DEBUG Acquired lock resource="rustup"
2026-09-19T19:35:18.944386Z TRACE Executing `/home/user/.cache/prek/tools/rustup/rustup toolchain list -v`
2026-09-19T19:35:18.949360Z DEBUG No system rust matches the requested version rust_request=Range(VersionReq { comparators: [Comparator { op: GreaterEq, major: 1, minor: Some(95), patch: None, pre: Prerelease("") }] }, ">=1.95")
2026-09-19T19:35:18.949397Z TRACE Executing `/home/user/.cache/prek/tools/rustup/rustup toolchain list -v`
2026-09-19T19:35:18.953177Z TRACE Executing `/nix/store/msr1v91ybfw6j12rs5mfl8ghb2rqsnsr-git-2.55.0/bin/git -c core.useBuiltinFSMonitor=false ls-remote --tags https://github.com/rust-lang/rust`
2026-09-19T19:35:19.667388Z DEBUG Installing Rust toolchain toolchain=1.98.1
2026-09-19T19:35:19.667427Z TRACE Executing `/home/user/.cache/prek/tools/rustup/rustup toolchain install --no-self-update --profile minimal 1.98.1`
2026-09-19T19:36:02.500534Z TRACE Executing `/home/user/.cache/prek/tools/rustup/toolchains/1.98.1-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-09-19T19:36:02.508145Z TRACE Released lock path=/home/user/.cache/prek/tools/rustup/.lock
2026-09-19T19:36:02.508550Z DEBUG Installed hook `test-rust-version` in `/home/user/.cache/prek/hooks/rust-W3wo3tD1qStmo7PN2bCu`
2026-09-19T19:36:02.508660Z DEBUG Found installed environment for hook `test-rust-path` at `/home/user/.cache/prek/hooks/rust-W3wo3tD1qStmo7PN2bCu`
2026-09-19T19:36:02.508676Z DEBUG Found installed environment for hook `test-cargo-version` at `/home/user/.cache/prek/hooks/rust-W3wo3tD1qStmo7PN2bCu`
2026-09-19T19:36:02.508699Z DEBUG Found installed environment for hook `test-cargo-path` at `/home/user/.cache/prek/hooks/rust-W3wo3tD1qStmo7PN2bCu`
2026-09-19T19:36:02.508787Z TRACE Released lock path=/home/user/.cache/prek/.lock
2026-09-19T19:36:02.508947Z TRACE Files for project `.` after filtered: 2
2026-09-19T19:36:02.508969Z TRACE diff_worktree{path="/tmp/test"}: Executing `/nix/store/msr1v91ybfw6j12rs5mfl8ghb2rqsnsr-git-2.55.0/bin/git -c core.useBuiltinFSMonitor=false diff --full-index --no-ext-diff --no-textconv --ignore-submodules -- /tmp/test`
2026-09-19T19:36:02.511769Z TRACE diff_worktree{path="/tmp/test"}: close time.busy=253µs time.idle=2.55ms
2026-09-19T19:36:02.511818Z DEBUG Running priority group with priority 0: ["test-rust-version"]
2026-09-19T19:36:02.511831Z TRACE Files for hook `test-rust-version` after filtering matched=true filenames=0
2026-09-19T19:36:02.512043Z TRACE run{hook_id=test-rust-version language=rust}: Running test-rust-version total_files=0 concurrency=12
2026-09-19T19:36:02.512150Z TRACE run{hook_id=test-rust-version language=rust}: Executing `cd /tmp/test && /home/user/.cache/prek/tools/rustup/toolchains/1.98.1-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-09-19T19:36:02.519925Z  INFO run{hook_id=test-rust-version language=rust}: close time.busy=682µs time.idle=7.39ms
2026-09-19T19:36:02.519994Z TRACE diff_worktree{path="/tmp/test"}: Executing `/nix/store/msr1v91ybfw6j12rs5mfl8ghb2rqsnsr-git-2.55.0/bin/git -c core.useBuiltinFSMonitor=false diff --full-index --no-ext-diff --no-textconv --ignore-submodules -- /tmp/test`
2026-09-19T19:36:02.521866Z TRACE diff_worktree{path="/tmp/test"}: close time.busy=297µs time.idle=1.58ms
2026-09-19T19:36:02.521932Z DEBUG Running priority group with priority 1: ["test-rust-path"]
2026-09-19T19:36:02.521945Z TRACE Files for hook `test-rust-path` after filtering matched=true filenames=0
2026-09-19T19:36:02.522078Z TRACE run{hook_id=test-rust-path language=rust}: Running test-rust-path total_files=0 concurrency=12
2026-09-19T19:36:02.522166Z TRACE run{hook_id=test-rust-path language=rust}: Executing `cd /tmp/test && /nix/store/78qwx7m2n6msg81zs4zzjzfqm3a3i8vv-which-2.25/bin/which rustc`
2026-09-19T19:36:02.523104Z  INFO run{hook_id=test-rust-path language=rust}: close time.busy=519µs time.idle=628µs
2026-09-19T19:36:02.523141Z TRACE diff_worktree{path="/tmp/test"}: Executing `/nix/store/msr1v91ybfw6j12rs5mfl8ghb2rqsnsr-git-2.55.0/bin/git -c core.useBuiltinFSMonitor=false diff --full-index --no-ext-diff --no-textconv --ignore-submodules -- /tmp/test`
2026-09-19T19:36:02.524795Z TRACE diff_worktree{path="/tmp/test"}: close time.busy=234µs time.idle=1.42ms
2026-09-19T19:36:02.524830Z DEBUG Running priority group with priority 2: ["test-cargo-version"]
2026-09-19T19:36:02.524841Z TRACE Files for hook `test-cargo-version` after filtering matched=true filenames=0
2026-09-19T19:36:02.525168Z TRACE run{hook_id=test-cargo-version language=rust}: Running test-cargo-version total_files=0 concurrency=12
2026-09-19T19:36:02.525272Z TRACE run{hook_id=test-cargo-version language=rust}: Executing `cd /tmp/test && /home/user/.cache/prek/tools/rustup/toolchains/1.98.1-x86_64-unknown-linux-gnu/bin/cargo --version`
2026-09-19T19:36:02.563822Z  INFO run{hook_id=test-cargo-version language=rust}: close time.busy=831µs time.idle=38.1ms
2026-09-19T19:36:02.563904Z TRACE diff_worktree{path="/tmp/test"}: Executing `/nix/store/msr1v91ybfw6j12rs5mfl8ghb2rqsnsr-git-2.55.0/bin/git -c core.useBuiltinFSMonitor=false diff --full-index --no-ext-diff --no-textconv --ignore-submodules -- /tmp/test`
2026-09-19T19:36:02.566220Z TRACE diff_worktree{path="/tmp/test"}: close time.busy=393µs time.idle=1.93ms
2026-09-19T19:36:02.566283Z DEBUG Running priority group with priority 3: ["test-cargo-path"]
2026-09-19T19:36:02.566301Z TRACE Files for hook `test-cargo-path` after filtering matched=true filenames=0
2026-09-19T19:36:02.566422Z TRACE run{hook_id=test-cargo-path language=rust}: Running test-cargo-path total_files=0 concurrency=12
2026-09-19T19:36:02.566537Z TRACE run{hook_id=test-cargo-path language=rust}: Executing `cd /tmp/test && /nix/store/78qwx7m2n6msg81zs4zzjzfqm3a3i8vv-which-2.25/bin/which cargo`
2026-09-19T19:36:02.567516Z  INFO run{hook_id=test-cargo-path language=rust}: close time.busy=655µs time.idle=546µs
2026-09-19T19:36:02.567572Z TRACE diff_worktree{path="/tmp/test"}: Executing `/nix/store/msr1v91ybfw6j12rs5mfl8ghb2rqsnsr-git-2.55.0/bin/git -c core.useBuiltinFSMonitor=false diff --full-index --no-ext-diff --no-textconv --ignore-submodules -- /tmp/test`
2026-09-19T19:36:02.569488Z TRACE diff_worktree{path="/tmp/test"}: close time.busy=285µs time.idle=1.64ms
2026-09-19T19:36:02.569560Z DEBUG Running priority group with priority 4: ["test-local-version"]
2026-09-19T19:36:02.569581Z TRACE Files for hook `test-local-version` after filtering matched=true filenames=0
2026-09-19T19:36:02.569837Z TRACE run{hook_id=test-local-version language=system}: Running test-local-version total_files=0 concurrency=12
2026-09-19T19:36:02.569951Z TRACE run{hook_id=test-local-version language=system}: Executing `cd /tmp/test && /run/current-system/sw/bin/sh -e /home/user/.cache/prek/scratch/.tmpjygKnS/entry.sh`
2026-09-19T19:36:02.775762Z  INFO run{hook_id=test-local-version language=system}: close time.busy=794µs time.idle=205ms
2026-09-19T19:36:02.775810Z TRACE diff_worktree{path="/tmp/test"}: Executing `/nix/store/msr1v91ybfw6j12rs5mfl8ghb2rqsnsr-git-2.55.0/bin/git -c core.useBuiltinFSMonitor=false diff --full-index --no-ext-diff --no-textconv --ignore-submodules -- /tmp/test`
2026-09-19T19:36:02.777078Z TRACE diff_worktree{path="/tmp/test"}: close time.busy=322µs time.idle=951µs
test-rust-version........................................................Passed
- hook id: test-rust-version
- duration: 0.01s

  rustc 1.98.1 (48a229cea 2026-09-01)
test-rust-path...........................................................Passed
- hook id: test-rust-path
- duration: 0.00s

  /home/user/.cache/prek/tools/rustup/toolchains/1.98.1-x86_64-unknown-linux-gnu/bin/rustc
test-cargo-version.......................................................Passed
- hook id: test-cargo-version
- duration: 0.04s

  cargo 1.98.1 (797e8a9bc 2026-08-05)
test-cargo-path..........................................................Passed
- hook id: test-cargo-path
- duration: 0.00s

  /home/user/.cache/prek/tools/rustup/toolchains/1.98.1-x86_64-unknown-linux-gnu/bin/cargo
test-local-version.......................................................Passed
- hook id: test-local-version
- duration: 0.21s

  rustc 1.95.0 (59807616e 2026-04-14) (built from a source tarball)
  /nix/store/js1dvxbwhjjq2470qg998s6cakhky97p-rustc-wrapper-1.95.0/bin/rustc
  cargo 1.95.0 (f2d3ce0bd 2026-03-21)
  /nix/store/b0fj70mrd9zy78b0ylxqzfwqaxbfsm30-cargo-1.95.0/bin/cargo