{"record":{"id":"e67820a1af1b0e63","repo":"zylon-ai/private-gpt","slug":"uv-lock-failed","errorCode":null,"errorMessage":"`uv lock` failed","messagePattern":"`uv lock` failed","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"scripts/set_version.py","lineNumber":59,"sourceCode":"    updated, count = re.subn(\n        r'(?m)^version = \"[^\"]+\"$',\n        f'version = \"{version}\"',\n        content,\n        count=1,\n    )\n    if count != 1:\n        raise RuntimeError(\"Failed to update project version in pyproject.toml\")\n    write_text(PYPROJECT, updated)\n\n\ndef refresh_uv_lock() -> None:\n    result = subprocess.run(\n        [\"uv\", \"lock\"],\n        cwd=REPO_ROOT,\n        check=False,\n    )\n    if result.returncode != 0:\n        raise RuntimeError(\"`uv lock` failed\")\n\n\ndef main() -> int:\n    args = parse_args()\n\n    update_version_txt(args.version)\n    update_pyproject(args.version)\n\n    if not args.no_lock:\n        refresh_uv_lock()\n\n    print(f\"Updated local version to {args.version}\")\n    if args.no_lock:\n        print(\"Skipped uv.lock refresh\")\n\n    return 0\n\n","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/scripts/set_version.py#L41-L77","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Reproduce the failure to see the real error: run `uv lock` manually in the repo root and read its output","Fix the environmental cause: network/proxy access, UV_INDEX credentials, or uv installation (curl install, ensure PATH)","If the lock step must be skipped (offline), pass --no-lock to set_version.py and regenerate the lock later on a connected machine","If resolution genuinely conflicts, adjust constraints in pyproject.toml or clear uv.lock and regenerate deliberately (review the diff)"],"exampleFix":"# before\npython scripts/set_version.py 1.2.3\n# RuntimeError: `uv lock` failed\n\n# after (diagnose first)\nuv lock -v\n# fix auth/network, or:\npython scripts/set_version.py 1.2.3 --no-lock","handlingStrategy":"retry","validationCode":"import shutil, subprocess\n\ndef uv_lock_available() -> bool:\n    if shutil.which(\"uv\") is None:\n        return False\n    r = subprocess.run([\"uv\", \"--version\"], capture_output=True)\n    return r.returncode == 0","typeGuard":"null","tryCatchPattern":"import subprocess, time\n\ndef refresh_uv_lock_retry(attempts: int = 3) -> None:\n    for i in range(attempts):\n        r = subprocess.run([\"uv\", \"lock\"], cwd=REPO_ROOT)\n        if r.returncode == 0:\n            return\n        time.sleep(2 ** i)\n    raise RuntimeError(\"`uv lock` failed after retries - check network/index credentials\")","preventionTips":["Run `uv lock` manually before invoking set_version.py so failures surface with full output","Ensure uv is installed and on PATH in CI images and that index credentials (UV_INDEX_*) are configured","Use --no-lock for offline version bumps, then regenerate the lock on a connected machine","Watch returncode 127 separately - it means uv is missing, not that resolution failed"],"tags":["versioning","build","uv","lockfile","network"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}