search you tried in the issue tracker
rust cargo
describe your issue
I have created a custom hook to make the issue easier to see.
When I create a hook definition with language: rust the hook fails to run because it can not find a rust command (cargo). The documentation says the the rust language should be bootstrapped.
Here is the command output (other hooks trimmed);
$ pre-commit run rust-fmt --all-files
ARNING] The 'rev' field of repo 'https://github.com/alsutton/rust-pre-commit.git' appears to be a mutable reference (moving tag / branch). Mutable references are never updated after first install and are not supported. See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details. Hint: `pre-commit autoupdate` often fixes this.
[INFO] Initializing environment for https://github.com/alsutton/rust-pre-commit.git.
[INFO] Installing environment for https://github.com/alsutton/rust-pre-commit.git.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('cargo', 'install', '--bins', '--root', '/Users/alansutton/.cache/pre-commit/repofnp573xu/rustenv-1.87.0', '--path', '.')
return code: 1
stdout:
Executable `cargo` not found
stderr: (none)
Check the log at /Users/alansutton/.cache/pre-commit/pre-commit.log
Further information
The root referred to in the log does not have an installed rust version;
$ ls -l /Users/alansutton/.cache/pre-commit/repofnp573xu/rustenv-1.87.0
ls: /Users/alansutton/.cache/pre-commit/repofnp573xu/rustenv-1.87.0: No such file or directory
$ ls -l /Users/alansutton/.cache/pre-commit/repofnp573xu/
total 8
-rw-r--r--@ 1 alansutton staff 1066 6 May 17:17 LICENSE
$
pre-commit --version
pre-commit 4.5.1
.pre-commit-config.yaml
minimum_pre_commit_version: "4.2.0"
default_language_version:
python: python3
rust: 1.87.0
repos:
- repo: https://github.com/alsutton/rust-pre-commit.git
rev: main
hooks:
- id: rust-fmt
~/.cache/pre-commit/pre-commit.log (if present)
version information
pre-commit version: 4.5.1
git --version: git version 2.54.0
sys.version:
3.14.4 (main, Apr 7 2026, 13:13:20) [Clang 21.0.0 (clang-2100.0.123.102)]
sys.executable: /Users/alansutton/.local/pipx/venvs/pre-commit/bin/python
os.name: posix
sys.platform: darwin
error information
An unexpected error has occurred: CalledProcessError: command: ('cargo', 'install', '--bins', '--root', '/Users/alansutton/.cache/pre-commit/repofnp573xu/rustenv-1.87.0', '--path', '.')
return code: 1
stdout:
Executable `cargo` not found
stderr: (none)
Traceback (most recent call last):
File "/Users/alansutton/.local/pipx/venvs/pre-commit/lib/python3.14/site-packages/pre_commit/error_handler.py", line 73, in error_handler
yield
File "/Users/alansutton/.local/pipx/venvs/pre-commit/lib/python3.14/site-packages/pre_commit/main.py", line 429, in main
return run(args.config, store, args)
File "/Users/alansutton/.local/pipx/venvs/pre-commit/lib/python3.14/site-packages/pre_commit/commands/run.py", line 443, in run
install_hook_envs(to_install, store)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/Users/alansutton/.local/pipx/venvs/pre-commit/lib/python3.14/site-packages/pre_commit/repository.py", line 229, in install_hook_envs
_hook_install(hook)
~~~~~~~~~~~~~^^^^^^
File "/Users/alansutton/.local/pipx/venvs/pre-commit/lib/python3.14/site-packages/pre_commit/repository.py", line 85, in _hook_install
lang.install_environment(
~~~~~~~~~~~~~~~~~~~~~~~~^
hook.prefix, hook.language_version, hook.additional_dependencies,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/alansutton/.local/pipx/venvs/pre-commit/lib/python3.14/site-packages/pre_commit/languages/rust.py", line 157, in install_environment
cmd_output_b(
~~~~~~~~~~~~^
'cargo', 'install', '--bins', '--root', envdir, *args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cwd=prefix.prefix_dir,
^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/alansutton/.local/pipx/venvs/pre-commit/lib/python3.14/site-packages/pre_commit/util.py", line 111, in cmd_output_b
raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('cargo', 'install', '--bins', '--root', '/Users/alansutton/.cache/pre-commit/repofnp573xu/rustenv-1.87.0', '--path', '.')
return code: 1
stdout:
Executable `cargo` not found
stderr: (none)
search you tried in the issue tracker
rust cargo
describe your issue
I have created a custom hook to make the issue easier to see.
When I create a hook definition with
language: rustthe hook fails to run because it can not find a rust command (cargo). The documentation says the the rust language should be bootstrapped.Here is the command output (other hooks trimmed);
Further information
The root referred to in the log does not have an installed rust version;
pre-commit --version
pre-commit 4.5.1
.pre-commit-config.yaml
~/.cache/pre-commit/pre-commit.log (if present)
version information
error information