{"record":{"id":"589570dfb29342eb","repo":"astral-sh/ruff","slug":"failed-to-create-virtual-environment","errorCode":null,"errorMessage":"Failed to create virtual environment: {}","messagePattern":"Failed to create virtual environment: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_benchmark/src/real_world_projects.rs","lineNumber":287,"sourceCode":"        .arg(\"--version\")\n        .output()\n        .context(\"Failed to execute uv version check.\")?;\n\n    if !uv_check.status.success() {\n        anyhow::bail!(\n            \"uv is not installed or not found in PATH. If you need to install it, follow the instructions at https://docs.astral.sh/uv/getting-started/installation/\"\n        );\n    }\n\n    let python_version_str = python_version.to_string();\n\n    let output = Command::new(\"uv\")\n        .args([\"venv\", \"--python\", &python_version_str, \"--allow-existing\"])\n        .arg(venv_path)\n        .output()\n        .context(\"Failed to execute uv venv command\")?;\n\n    anyhow::ensure!(\n        output.status.success(),\n        \"Failed to create virtual environment: {}\",\n        String::from_utf8_lossy(&output.stderr)\n    );\n\n    if dependencies.is_empty() {\n        tracing::debug!(\"No dependencies to install for project '{}'\", name);\n        return Ok(());\n    }\n\n    // Install dependencies with date constraint in the isolated environment\n    let mut cmd = Command::new(\"uv\");\n    cmd.args([\n        \"pip\",\n        \"install\",\n        \"--python\",\n        venv_path.to_str().unwrap(),\n        \"--exclude-newer\",","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/astral-sh/ruff/blob/672bb4edf04c84f8b0753346359daee4057158f2/crates/ruff_benchmark/src/real_world_projects.rs#L269-L305","documentation":"The benchmark harness creates the cached virtual environment with `uv venv --python <version> --allow-existing` under target/benchmark_cache/<name>/.venv; a nonzero exit raises this error including uv's stderr.","triggerScenarios":"The pinned Python version is neither installed locally nor downloadable (offline machine, blocked python-build-standalone download), or the venv path has permission/stale-state problems.","commonSituations":"Air-gapped CI where uv cannot fetch interpreters; system lacking the pinned Python major.minor; leftover root-owned .venv from an earlier privileged run.","solutions":["Read the embedded stderr — it names the missing interpreter or underlying error","Pre-install the required Python version (`uv python install <version>`) or allow network access so uv can download it","Remove a stale or broken environment: delete target/benchmark_cache/<name>/.venv and rerun"],"exampleFix":"# before\n bench run fails: Failed to create virtual environment: error: no interpreter found ...\n\n# after\nuv python install 3.12 && cargo bench --bench <real-world-bench>","handlingStrategy":"retry","validationCode":"uv python list 2>/dev/null | grep -q \"$python_version\" || uv python install \"$python_version\"\ncargo bench --bench \"$bench\"","typeGuard":null,"tryCatchPattern":"for i in 1 2; do\n  cargo bench --bench \"$bench\" && break\n  echo \"venv setup attempt $i failed; clearing venv\" >&2\n  rm -rf \"target/benchmark_cache/$project/.venv\"\ndone","preventionTips":["Pre-install every pinned Python version in the benchmark environment","Allow network access for uv interpreter downloads on first run","Never create or modify benchmark venvs with sudo"],"tags":["benchmark","python","virtualenv"],"backgroundTag":null,"analyzedSha":"672bb4edf04c84f8b0753346359daee4057158f2","analyzedAt":"2026-08-16T08:54:05.464Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}