zylon-ai/private-gpt · error · RuntimeError

`uv lock` failed

Error message

`uv lock` failed

What it means

Raised by refresh_uv_lock in scripts/set_version.py when the subprocess `uv lock` exits with a non-zero code after the version was bumped in VERSION_TXT and pyproject.toml. uv lock regenerates uv.lock to match the new version; failure means uv could not resolve dependencies (network errors, unreachable private index, conflicting requirements) or uv is not installed/old - the message distinguishes this step from the file edits that precede it.

Source

Thrown at scripts/set_version.py:59

    updated, count = re.subn(
        r'(?m)^version = "[^"]+"$',
        f'version = "{version}"',
        content,
        count=1,
    )
    if count != 1:
        raise RuntimeError("Failed to update project version in pyproject.toml")
    write_text(PYPROJECT, updated)


def refresh_uv_lock() -> None:
    result = subprocess.run(
        ["uv", "lock"],
        cwd=REPO_ROOT,
        check=False,
    )
    if result.returncode != 0:
        raise RuntimeError("`uv lock` failed")


def main() -> int:
    args = parse_args()

    update_version_txt(args.version)
    update_pyproject(args.version)

    if not args.no_lock:
        refresh_uv_lock()

    print(f"Updated local version to {args.version}")
    if args.no_lock:
        print("Skipped uv.lock refresh")

    return 0

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Reproduce the failure to see the real error: run `uv lock` manually in the repo root and read its output
  2. Fix the environmental cause: network/proxy access, UV_INDEX credentials, or uv installation (curl install, ensure PATH)
  3. If the lock step must be skipped (offline), pass --no-lock to set_version.py and regenerate the lock later on a connected machine
  4. If resolution genuinely conflicts, adjust constraints in pyproject.toml or clear uv.lock and regenerate deliberately (review the diff)

Example fix

# before
python scripts/set_version.py 1.2.3
# RuntimeError: `uv lock` failed

# after (diagnose first)
uv lock -v
# fix auth/network, or:
python scripts/set_version.py 1.2.3 --no-lock
Defensive patterns

Strategy: retry

Validate before calling

import shutil, subprocess

def uv_lock_available() -> bool:
    if shutil.which("uv") is None:
        return False
    r = subprocess.run(["uv", "--version"], capture_output=True)
    return r.returncode == 0

Type guard

null

Try / catch

import subprocess, time

def refresh_uv_lock_retry(attempts: int = 3) -> None:
    for i in range(attempts):
        r = subprocess.run(["uv", "lock"], cwd=REPO_ROOT)
        if r.returncode == 0:
            return
        time.sleep(2 ** i)
    raise RuntimeError("`uv lock` failed after retries - check network/index credentials")

Prevention

When it happens

Trigger: Running set_version.py in an offline environment where uv cannot reach PyPI; a private index (keyring/auth) not configured for uv; dependency resolution conflicts introduced by the new version constraints; uv missing from PATH (returncode 127) or an old uv that cannot parse the lockfile.

Common situations: Release jobs in CI sandboxes without network egress; developers bumping versions locally with a corporate proxy blocking uv; lockfile format mismatch after a uv upgrade; running the script with --no-lock forgotten after intentionally skipping regeneration elsewhere.

Related errors


AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15). Data as JSON: /api/errors/e67820a1af1b0e63. Report an issue: GitHub.