astral-sh/ruff · error
Failed to create virtual environment: {}
Error message
Failed to create virtual environment: {} What it means
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.
Source
Thrown at crates/ruff_benchmark/src/real_world_projects.rs:287
.arg("--version")
.output()
.context("Failed to execute uv version check.")?;
if !uv_check.status.success() {
anyhow::bail!(
"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/"
);
}
let python_version_str = python_version.to_string();
let output = Command::new("uv")
.args(["venv", "--python", &python_version_str, "--allow-existing"])
.arg(venv_path)
.output()
.context("Failed to execute uv venv command")?;
anyhow::ensure!(
output.status.success(),
"Failed to create virtual environment: {}",
String::from_utf8_lossy(&output.stderr)
);
if dependencies.is_empty() {
tracing::debug!("No dependencies to install for project '{}'", name);
return Ok(());
}
// Install dependencies with date constraint in the isolated environment
let mut cmd = Command::new("uv");
cmd.args([
"pip",
"install",
"--python",
venv_path.to_str().unwrap(),
"--exclude-newer",View on GitHub (pinned to 672bb4edf0)
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
Example fix
# before bench run fails: Failed to create virtual environment: error: no interpreter found ... # after uv python install 3.12 && cargo bench --bench <real-world-bench>
Defensive patterns
Strategy: retry
Validate before calling
uv python list 2>/dev/null | grep -q "$python_version" || uv python install "$python_version" cargo bench --bench "$bench"
Try / catch
for i in 1 2; do cargo bench --bench "$bench" && break echo "venv setup attempt $i failed; clearing venv" >&2 rm -rf "target/benchmark_cache/$project/.venv" done
Prevention
- 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
When it happens
Trigger: 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.
Common situations: Air-gapped CI where uv cannot fetch interpreters; system lacking the pinned Python major.minor; leftover root-owned .venv from an earlier privileged run.
Related errors
- Could not determine source kind for file: {}
- Could not determine source kind for file: {}
- Git fetch of commit {} failed: {}
- Git checkout of commit {} failed: {}
- Git clone failed: {}
AI-assisted analysis of astral-sh/ruff@672bb4edf0 (2026-08-16).
Data as JSON: /api/errors/589570dfb29342eb.
Report an issue: GitHub.