Skip to content

One invalid Rust toolchain causes prek to fail #1695

@m4tx

Description

@m4tx

Summary

When running a Rust-based hook, I've got the following error:

error: Failed to install hook `oxipng`
  caused by: Failed to install rust
  caused by: Failed to read version from /home/m4tx/projects/rust/build/host/stage0-sysroot/bin/rustc
  caused by: Run command `rustc version` failed
  caused by: No such file or directory (os error 2)

This was very concerning for me at first, since /home/m4tx/projects is a very arbitrary path that I happen to store various repositories in, and I would never expect prek to look for anything in there. Running prek with -vvv did shine some light on this:

2026-02-26T16:45:23.963699Z TRACE Executing `/home/m4tx/.rustup/toolchains/nightly-2025-07-03-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.963942Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.42.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.964608Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.57.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.964848Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.60-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.965053Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.64.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.965181Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.70.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.965471Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.75.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.966651Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.77.2-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.972872Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.78.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.975137Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.79.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.977357Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.80.1-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.977749Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.81.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.977995Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.84.1-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.978252Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.85-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.978423Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.85.1-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.978681Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.93-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.983378Z TRACE Executing `/home/m4tx/projects/rust/build/host/stage0-sysroot/bin/rustc --version`

Turns out that I was trying to compile Rust from scratch, which resulted in the toolchain being added to rustup. For the next 6 months ran into any issues because of this (since I had a number of other perfectly working toolchains installed) until I tried prek. Removing the problematic toolchain from rustup has fixed the problem.

I don't think that prek should fail on any when it encounters failure using any toolchain; rather, I would expect it to work if at least one Rust toolchain is usable.

Willing to submit a PR?

  • Yes — I’m willing to open a PR to fix this.

Platform

Arch Linux, Linux 6.12.74-1-lts x86_64 GNU/Linux

Version

prek 0.3.3

.pre-commit-config.yaml

repos:
  - repo: https://github.com/oxipng/oxipng
    rev: v9.1.4
    hooks:
      - id: oxipng
        args: ["-o", "max", "--strip", "safe", "--alpha"]

Log file

2026-02-26T16:45:23.937725Z DEBUG prek: 0.3.3
2026-02-26T16:45:23.937755Z DEBUG Args: ["prek", "-vvv"]
2026-02-26T16:45:23.938885Z TRACE get_root: close time.busy=1.10ms time.idle=2.87µs
2026-02-26T16:45:23.938914Z DEBUG Git root: /home/m4tx/projects/m4txblog
2026-02-26T16:45:23.938928Z TRACE Executing `/usr/bin/git ls-files --unmerged`
2026-02-26T16:45:23.939978Z DEBUG Found workspace root at `/home/m4tx/projects/m4txblog`
2026-02-26T16:45:23.939988Z TRACE Include selectors: ``
2026-02-26T16:45:23.939993Z TRACE Skip selectors: ``
2026-02-26T16:45:23.940045Z DEBUG discover{root="/home/m4tx/projects/m4txblog" config=None refresh=false}: Loaded workspace from cache
2026-02-26T16:45:23.940061Z DEBUG discover{root="/home/m4tx/projects/m4txblog" config=None refresh=false}: Loading project configuration path=.pre-commit-config.yaml
2026-02-26T16:45:23.940757Z TRACE discover{root="/home/m4tx/projects/m4txblog" config=None refresh=false}: close time.busy=748µs time.idle=1.18µs
2026-02-26T16:45:23.940780Z TRACE Executing `/usr/bin/git diff --exit-code --name-only -z /home/m4tx/projects/m4txblog/.pre-commit-config.yaml`
2026-02-26T16:45:23.941978Z TRACE Checking lock resource="store" path=/home/m4tx/.cache/prek/.lock
2026-02-26T16:45:23.941999Z DEBUG Acquired lock resource="store"
2026-02-26T16:45:23.942414Z TRACE Using go.mod-derived language_version hook=yamlfmt version=>= 1.21.0
2026-02-26T16:45:23.942428Z TRACE Skipping reading PEP 723 metadata for hook `taplo-fmt` because it already has `additional_dependencies`
2026-02-26T16:45:23.942500Z TRACE No requires-python found in pyproject.toml hook=beautysh
2026-02-26T16:45:23.942539Z TRACE No requires-python found in pyproject.toml hook=shellcheck
2026-02-26T16:45:23.942570Z TRACE No requires-python found in pyproject.toml hook=hadolint
2026-02-26T16:45:23.942645Z TRACE Using pyproject.toml-derived language_version hook=djlint version=>=3.9
2026-02-26T16:45:23.942673Z DEBUG Hooks going to run: ["check-added-large-files", "check-case-conflict", "check-executables-have-shebangs", "check-toml", "detect-private-key", "end-of-file-fixer", "mixed-line-ending", "trailing-whitespace", "yamlfmt", "taplo-fmt", "cargo-fmt", "cargo-clippy", "beautysh", "shellcheck", "hadolint", "oxipng", "djlint"]
2026-02-26T16:45:23.943443Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-FyObJ8sY1LiR7sAKE1L6/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-FyObJ8sY1LiR7sAKE1L6
2026-02-26T16:45:23.943457Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-HHuG4cKRiOVzM3qGb6ss/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-HHuG4cKRiOVzM3qGb6ss
2026-02-26T16:45:23.943465Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-QbZzBUQfSZFtRdaVE8NL/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-QbZzBUQfSZFtRdaVE8NL
2026-02-26T16:45:23.943473Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-LhWxECYz2d70EzKVjsmh/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-LhWxECYz2d70EzKVjsmh
2026-02-26T16:45:23.943484Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-7YuF5G4WLkVq6LWHrMtz/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-7YuF5G4WLkVq6LWHrMtz
2026-02-26T16:45:23.943491Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-7ak4WzdX9JUR8HcC6O5p/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-7ak4WzdX9JUR8HcC6O5p
2026-02-26T16:45:23.943498Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-6cplfcUEyPyw6JpRWxGI/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-6cplfcUEyPyw6JpRWxGI
2026-02-26T16:45:23.943508Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-lwkuRxnh9JeXKKX3Qyw0/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-lwkuRxnh9JeXKKX3Qyw0
2026-02-26T16:45:23.943516Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-8Au7cNq09aOQbybqDBFG/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-8Au7cNq09aOQbybqDBFG
2026-02-26T16:45:23.943526Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-OgWVAVNu33iSWtRs0UVd/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-OgWVAVNu33iSWtRs0UVd
2026-02-26T16:45:23.943532Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-1SquCI7ANmZ0Lgb5DymF/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-1SquCI7ANmZ0Lgb5DymF
2026-02-26T16:45:23.943538Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-yQMOqE3RUqnio1WM7de2/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-yQMOqE3RUqnio1WM7de2
2026-02-26T16:45:23.943544Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-rKhhF0oi9nzg3CeQF0dK/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-rKhhF0oi9nzg3CeQF0dK
2026-02-26T16:45:23.943550Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-Xz43mREJYCXuFtlprWjp/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-Xz43mREJYCXuFtlprWjp
2026-02-26T16:45:23.943556Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-U26PbDyVUlhlq1D63F0f/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-U26PbDyVUlhlq1D63F0f
2026-02-26T16:45:23.943562Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-8V8qsGUPhwEvoPo0Zb6Y/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-8V8qsGUPhwEvoPo0Zb6Y
2026-02-26T16:45:23.943568Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-CSxbBP8W2yBqFeokZ1E8/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-CSxbBP8W2yBqFeokZ1E8
2026-02-26T16:45:23.943574Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-aPj6Yvh3e96YBmEoGZlQ/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-aPj6Yvh3e96YBmEoGZlQ
2026-02-26T16:45:23.943580Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-7fFsK80IBBLWzv6MSpwv/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-7fFsK80IBBLWzv6MSpwv
2026-02-26T16:45:23.943586Z  WARN Skipping invalid installed hook err=failed to read from file `/home/m4tx/.cache/prek/hooks/python-tvRfW0xVrwxVLifqmOVd/.prek-hook.json`: No such file or directory (os error 2) path=/home/m4tx/.cache/prek/hooks/python-tvRfW0xVrwxVLifqmOVd
2026-02-26T16:45:23.943653Z TRACE Using system installed rustup at /usr/bin/rustup
2026-02-26T16:45:23.943665Z DEBUG Hook `check-added-large-files` is a meta or builtin hook, no installation needed
2026-02-26T16:45:23.943670Z DEBUG Hook `check-case-conflict` is a meta or builtin hook, no installation needed
2026-02-26T16:45:23.943675Z DEBUG Hook `check-executables-have-shebangs` is a meta or builtin hook, no installation needed
2026-02-26T16:45:23.943680Z DEBUG Hook `check-toml` is a meta or builtin hook, no installation needed
2026-02-26T16:45:23.943686Z DEBUG Hook `detect-private-key` is a meta or builtin hook, no installation needed
2026-02-26T16:45:23.943691Z DEBUG Hook `end-of-file-fixer` is a meta or builtin hook, no installation needed
2026-02-26T16:45:23.943695Z DEBUG Hook `mixed-line-ending` is a meta or builtin hook, no installation needed
2026-02-26T16:45:23.943700Z DEBUG Hook `trailing-whitespace` is a meta or builtin hook, no installation needed
2026-02-26T16:45:23.943706Z DEBUG Hook `cargo-fmt` does not need installation
2026-02-26T16:45:23.943711Z DEBUG Hook `cargo-clippy` does not need installation
2026-02-26T16:45:23.943718Z DEBUG Found installed environment for hook `yamlfmt` at `/home/m4tx/.cache/prek/hooks/golang-T8YZ8MqThemvD6aRFcFO`
2026-02-26T16:45:23.943746Z TRACE Executing `/usr/bin/python3.14 -I -c import sys, json
info = {
    "version": ".".join(map(str, sys.version_info[:3])),
    "base_exec_prefix": sys.base_exec_prefix,
}
print(json.dumps(info))
 [...]`
2026-02-26T16:45:23.943927Z TRACE Checking lock resource="rustup" path=/home/m4tx/.cache/prek/tools/rustup/.lock
2026-02-26T16:45:23.943941Z DEBUG Acquired lock resource="rustup"
2026-02-26T16:45:23.943957Z TRACE Executing `/usr/bin/rustup toolchain list -v`
2026-02-26T16:45:23.948688Z TRACE Executing `/usr/bin/rustup toolchain list -v`
2026-02-26T16:45:23.953715Z TRACE Executing `/home/m4tx/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.953859Z TRACE Executing `/home/m4tx/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.953958Z TRACE Executing `/home/m4tx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.954068Z TRACE Executing `/home/m4tx/.rustup/toolchains/nightly-2024-08-11-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.954174Z TRACE Executing `/home/m4tx/.rustup/toolchains/nightly-2024-09-23-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.954309Z TRACE Executing `/home/m4tx/.rustup/toolchains/nightly-2024-11-14-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.954423Z TRACE Executing `/home/m4tx/.rustup/toolchains/nightly-2025-02-22-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.954548Z TRACE Executing `/home/m4tx/.rustup/toolchains/nightly-2025-02-27-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.960363Z DEBUG Found installed environment for hook `taplo-fmt` at `/home/m4tx/.cache/prek/hooks/python-xJZzuG7TLt4arAwyMlpf`
2026-02-26T16:45:23.960442Z DEBUG Found installed environment for hook `beautysh` at `/home/m4tx/.cache/prek/hooks/python-FJ9SWwb4vVGT8mZmYAZ9`
2026-02-26T16:45:23.960452Z DEBUG Found installed environment for hook `shellcheck` at `/home/m4tx/.cache/prek/hooks/python-1n2w9vxOTWdgSaEyHCdk`
2026-02-26T16:45:23.960462Z DEBUG Found installed environment for hook `hadolint` at `/home/m4tx/.cache/prek/hooks/python-4NRu4vDu1I2oWOGzmI4p`
2026-02-26T16:45:23.960468Z DEBUG Found installed environment for hook `djlint` at `/home/m4tx/.cache/prek/hooks/python-yE1XO8FIDPY4gOj5ABCn`
2026-02-26T16:45:23.963699Z TRACE Executing `/home/m4tx/.rustup/toolchains/nightly-2025-07-03-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.963942Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.42.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.964608Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.57.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.964848Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.60-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.965053Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.64.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.965181Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.70.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.965471Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.75.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.966651Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.77.2-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.972872Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.78.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.975137Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.79.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.977357Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.80.1-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.977749Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.81.0-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.977995Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.84.1-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.978252Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.85-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.978423Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.85.1-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.978681Z TRACE Executing `/home/m4tx/.rustup/toolchains/1.93-x86_64-unknown-linux-gnu/bin/rustc --version`
2026-02-26T16:45:23.983378Z TRACE Executing `/home/m4tx/projects/rust/build/host/stage0-sysroot/bin/rustc --version`
2026-02-26T16:45:23.983718Z TRACE Released lock path=/home/m4tx/.cache/prek/tools/rustup/.lock
2026-02-26T16:45:23.983833Z TRACE Released lock path=/home/m4tx/.cache/prek/.lock
error: Failed to install hook `oxipng`
  caused by: Failed to install rust
  caused by: Failed to read version from /home/m4tx/projects/rust/build/host/stage0-sysroot/bin/rustc
  caused by: Run command `rustc version` failed
  caused by: No such file or directory (os error 2)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions