Skip to content

Python virtual environment creation fails #899

@Ch00k

Description

@Ch00k

Summary

prek is failing to create a Python virtualenv:

$ prek
error: Failed to install hook `ruff-check`
  caused by: Failed to create Python virtual environment
  caused by: command `create venv` exited with an error:

[status]
exit status: 2

[stderr]
error: the argument '--python-preference <PYTHON_PREFERENCE>' cannot be used with '--managed-python'
Usage: uv venv --no-project --no-config --no-python-downloads --python <PYTHON> --cache-dir <CACHE_DIR> <PATH>
For more information, try '--help'.

Platform

Ubuntu 22.04 amd64

Version

prek 0.2.8 (Homebrew/Linuxbrew)

.pre-commit-config.yaml

default_language_version:
  python: python3.12

repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.11.13
    hooks:
      - id: ruff-check
        args:
          - --fix
      - id: ruff-format

  - repo: https://github.com/djlint/djLint
    rev: v1.36.4
    hooks:
      - id: djlint-reformat-django
      #- id: djlint-django

  - repo: local
    hooks:
      - id: mypy
        name: mypy
        entry: uv run mypy
        args:
          - --config-file
          - pyproject.toml
        verbose: true
        language: system
        types:
          - python

Log file

2025-10-16T08:04:09.441656Z DEBUG prek: 0.2.8
2025-10-16T08:04:09.441678Z DEBUG Args: ["prek"]
2025-10-16T08:04:09.444358Z DEBUG Git root: /home/ay/projects/personal/mottle
2025-10-16T08:04:09.444396Z TRACE Executing `/home/linuxbrew/.linuxbrew/bin/git ls-files --unmerged`
2025-10-16T08:04:09.446826Z DEBUG Found workspace root at `/home/ay/projects/personal/mottle`
2025-10-16T08:04:09.446839Z TRACE Include selectors: ``
2025-10-16T08:04:09.446845Z TRACE Skip selectors: ``
2025-10-16T08:04:09.446915Z DEBUG discover{root="/home/ay/projects/personal/mottle" config=None refresh=false}: Loaded workspace from cache
2025-10-16T08:04:09.446940Z DEBUG discover{root="/home/ay/projects/personal/mottle" config=None refresh=false}: Loading project configuration path=.pre-commit-config.yaml
2025-10-16T08:04:09.447241Z TRACE discover{root="/home/ay/projects/personal/mottle" config=None refresh=false}: close time.busy=361µs time.idle=2.46µs
2025-10-16T08:04:09.447273Z TRACE Executing `/home/linuxbrew/.linuxbrew/bin/git diff --exit-code --name-only -z /home/ay/projects/personal/mottle/.pre-commit-config.yaml`
2025-10-16T08:04:09.450640Z TRACE Checking lock resource="store" path=/home/ay/.cache/prek/.lock
2025-10-16T08:04:09.450661Z DEBUG Acquired lock resource="store"
2025-10-16T08:04:09.451107Z DEBUG Hooks going to run: ["ruff-check", "ruff-format", "djlint-reformat-django", "mypy"]
2025-10-16T08:04:09.451264Z DEBUG No matching environment found for hook `mypy`, installing...
2025-10-16T08:04:09.451274Z DEBUG Hook `mypy` does not need installation
2025-10-16T08:04:09.451280Z DEBUG No matching environment found for hook `ruff-check`, installing...
2025-10-16T08:04:09.451423Z DEBUG Found uv in PATH: /home/linuxbrew/.linuxbrew/bin/uv
2025-10-16T08:04:09.455787Z TRACE Using system uv version 0.9.3 at /home/linuxbrew/.linuxbrew/bin/uv
2025-10-16T08:04:09.455816Z DEBUG Installing environment hook=ruff-check target=/home/ay/.cache/prek/hooks/python-WI5LdYNM6FBRU1Cm37td
2025-10-16T08:04:09.455834Z TRACE Executing `/home/linuxbrew/.linuxbrew/bin/uv venv /home/ay/.cache/prek/hooks/python-WI5LdYNM6FBRU1Cm37td --python-preference managed --no-project [...]`
2025-10-16T08:04:09.456154Z DEBUG No matching environment found for hook `djlint-reformat-django`, installing...
2025-10-16T08:04:09.456244Z TRACE Using system uv version 0.9.3 at /home/linuxbrew/.linuxbrew/bin/uv
2025-10-16T08:04:09.456251Z DEBUG Installing environment hook=djlint-reformat-django target=/home/ay/.cache/prek/hooks/python-rXJZiyltvsTuZNqJ5fMq
2025-10-16T08:04:09.456260Z TRACE Executing `/home/linuxbrew/.linuxbrew/bin/uv venv /home/ay/.cache/prek/hooks/python-rXJZiyltvsTuZNqJ5fMq --python-preference managed --no-project [...]`
2025-10-16T08:04:09.462443Z TRACE Released lock path=/home/ay/.cache/prek/.lock

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions