Skip to content

pixi install / pixi run doesn't handle multiple concurrent invocations very well #1482

Closed

Description

@pavelzw

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:

image

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):

image

Any ideas why this is the case?

Activity

  1. pavelzw commented on Jun 10, 2024

    @pavelzw
    CollaboratorAuthor

    a workaround for this is to add the following at the beginning of your .pre-commit-config.yaml:

          # ensure pixi environments are up to date
          # workaround for https://github.com/prefix-dev/pixi/issues/1482
          - id: pixi-install
            name: pixi-install
            entry: pixi install -e default -e lint
            language: system
            always_run: true
            require_serial: true
            pass_filenames: false
  2. added a commit that references this issue on Jul 8, 2024
  3. added a commit that references this issue on Sep 10, 2025
    89cddf1
  4. added a commit that references this issue on Oct 27, 2025
  5. baszalmstra commented on May 27, 2026

    @baszalmstra
    Contributor

    I wonder if this is still an issue!

  6. lucascolley commented on May 27, 2026

    @lucascolley
    Member

    I wonder if this is still an issue!

    looks like @Hofer-Julian hit this at prefix-dev/rattler-build#2387.

  7. Hofer-Julian commented on May 27, 2026

    @Hofer-Julian
    Member

    Yeah, I hit this all the time when using lefthook with parallel enabled

  8. pavelzw commented on May 27, 2026

    @pavelzw
    CollaboratorAuthor

    we are now just using something like this in lefthook:

    templates:
      run: run --as-is --quiet --no-progress
    no_auto_install: true
    pre-commit:
      fail_on_changes: always
      jobs:
        - name: pixi-install
          run: pixi install
        - group:
            parallel: true
            jobs:
              - name: ruff-check
                glob: "*.{py,pyi}"
                run: pixi {run} ruff check --fix --exit-non-zero-on-fix --force-exclude
              # ...

    with an initial install and then follow-up --as-is, it seems to be relatively stable

  9. lucascolley commented on May 27, 2026

    @lucascolley
    Member

    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?

  10. baszalmstra commented on May 27, 2026

    @baszalmstra
    Contributor

    Im working on a PR to ensure that parallel installations do not happen.

  11. crusaderky commented on May 27, 2026

    @crusaderky

    Yeah, I hit this all the time when using lefthook with parallel enabled

    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.

    # pixi.toml
    [feature.lint.dependencies]
    lefthook = "*"
    ruff = "*"
    mypy = "*"
    # ...
    
    [feature.lint.tasks]
    install-git-hooks = { cmd = "lefthook install", description = "Install pre-commit hooks" }
    update-dprint = { cmd = "dprint config update", description = "Update dprint plugins" }
    lint = { cmd = "lefthook run pre-commit --all-files --force", description = "Run all linters" }
    
    [environments]
    lint = ["lint"]
    #lefthook.yml
    pre-commit:
      parallel: true
      jobs:
        - name: ruff
          group:
            piped: true
            jobs:
              - name: ruff format
                run: ruff format
              - name: ruff check
                run: ruff check --fix --show-fixes
        - run: mypy
        # ...
  12. lucascolley commented on May 27, 2026

    @lucascolley
    Member

    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

  13. added 6 commits that reference this issue on May 28, 2026
    8173af1
    43226f0
    f83af55
    000ca65
    5217412
    88f4dbd
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