Closed
Description
In our pre-commit configuration, we use something like
exclude: (^env/|.pixi/)
repos:
- repo: local
hooks:
# prettier
- id: prettier
name: prettier
entry: pixi run -e lint prettier --write --list-different --ignore-unknown
language: system
types: [text]
files: \.(md|yml|yaml)$
# pre-commit-hooks
- id: trailing-whitespace-fixer
name: trailing-whitespace-fixer
entry: pixi run -e lint trailing-whitespace-fixer
language: system
types: [text]
- id: end-of-file-fixer
name: end-of-file-fixer
entry: pixi run -e lint end-of-file-fixer
language: system
types: [text]
- id: check-merge-conflict
name: check-merge-conflict
entry: pixi run -e lint check-merge-conflict --assume-in-merge
language: system
types: [text]
# typos
- id: typos
name: typos
entry: pixi run -e lint typos --force-exclude
language: system
types: [text]
require_serial: true
# cargo fmt and clippy
- id: cargo-fmt
name: cargo-fmt
entry: pixi run -e default cargo fmt --
language: system
require_serial: false
types: [rust]
- id: cargo-clippy
name: cargo-clippy
entry: pixi run -e default cargo clippy --all-targets --all-features --workspace -- -D warnings
pass_filenames: false
language: system
require_serial: false
types: [rust]
# taplo
- id: taplo
name: taplo
entry: pixi run -e lint taplo format
language: system
types: [toml]since it is a bad idea to let pre-commit manage lint dependencies when you have a proper package manager who can do that as well in a lint environment.
When running pre-commit run -a, it invokes a lot of pixi run ... processes that all try to install the environment if it doesn't exist.
This then leads to warnings/errors like this:
To be fair, how our pre-commit config looks is a bit hacky but I think pixi could write a lock file to .pixi to prevent parallel access.
Also, sort-of related, i'm not sure why I see a updating environment 'default' here since the default environment should already be installed (from the setup-pixi step):
Any ideas why this is the case?
Reacted by Moritz Wilksch, Julian Rüth, Brandon Maier and Lucas Colley
Metadata
Metadata
Assignees
Labels
No labels


Activity
pavelzw commentedon Jun 10, 2024
a workaround for this is to add the following at the beginning of your
.pre-commit-config.yaml:chore: use pre-commit with pixi (#1493)
fix(install): add file locking to prevent concurrent environment inst…
fix: lefthook parallel
baszalmstra commentedon May 27, 2026
I wonder if this is still an issue!
lucascolley commentedon May 27, 2026
looks like @Hofer-Julian hit this at prefix-dev/rattler-build#2387.
Hofer-Julian commentedon May 27, 2026
Yeah, I hit this all the time when using lefthook with parallel enabled
pavelzw commentedon May 27, 2026
we are now just using something like this in lefthook:
with an initial install and then follow-up
--as-is, it seems to be relatively stablelucascolley commentedon May 27, 2026
FWIW I haven't had problems with the naïve parallel approach on either this repo or array-api-extra. Not sure what the failure modes are, but possibly there is something linux-specific?
baszalmstra commentedon May 27, 2026
Im working on a PR to ensure that parallel installations do not happen.
crusaderky commentedon May 27, 2026
I've rigged lefthook to call the tools directly to solve this problem.
This way the pixi environment is initialised before starting lefthook and doesn't change halfway through.
lucascolley commentedon May 27, 2026
I believe the drawback with Guido's approach is that (in lack of further automation) you have two sources of truth for each lint sub-task, which can come apart
feat(install): serialize concurrent installs and recover from crashes
feat(install): serialize concurrent installs and recover from crashes
feat(install): serialize concurrent installs and recover from crashes
feat(install): serialize concurrent installs and recover from crashes
feat(install): serialize concurrent installs and recover from crashes
feat(install): serialize concurrent installs and recover from crashes