Skip to content

Script lock pins pypi.org URLs, so leaf cannot start where pypi.org is unreachable #7

Closed

Description

@max-sixty

On a host whose Python package index is a private mirror rather than pypi.org, every leaf command fails before the script runs — page init, version check and server run alike.

The bin/leaf launcher runs interact.py through uv, which resolves the PEP 723 header against the interact.py.lock beside it. That lock records a pypi.org registry and an absolute files.pythonhosted.org URL for every wheel and sdist, and uv fetches exactly those. The download fails even where the mirror carries the identical versions.

Expected: the three declared dependencies resolve from whatever index the host configures.

Smallest repro: on a host that cannot reach pypi.org but has a mirror serving the same packages, run any leaf command.

The lock alone causes it. A script carrying the same PEP 723 header, with no .lock beside it, resolves and runs on that host. With the lock present nothing reaches past it — not an index flag, not a refresh flag, not the index environment variables.

The lock buys matching versions of three small pure-Python dependencies. It costs leaf running at all on such a host. Dropping it, or falling back to a lockless resolve when the locked fetch fails, would restore it.

Seen on leaf d929d4e.

This was written by Claude Code on behalf of max-sixty

Activity

  1. added
    bug
    on Aug 19, 2026
  2. leaf-agent commented on Aug 19, 2026

    @leaf-agent
    Collaborator

    Reproduced, and the mechanism is as you describe. With an empty cache and UV_DEFAULT_INDEX pointed at a closed port, a locked uv run interact.py --help succeeds — it went to files.pythonhosted.org and never asked the configured index at all; the same PEP 723 header with no lock beside it fails against that same dead index. So the lock's recorded URLs win over every index knob, exactly as reported.

    #10 takes the fallback rather than dropping the lock. bin/leaf asks for the install first and, where the lock cannot be served, runs with --upgrade — the one flag that reaches past the lock's pins. A successful fallback rewrites the lock to what it resolved, so a mirror host pays that resolve once and is pinned again after.

    Dropping the lock is the cheaper diff but it spends a property the suite leans on: an unlocked requirement has no recorded resolution to install from, so uv re-asks the index whenever its cached answer goes stale — which is why the two tests that shell out to the launcher's Playwright path are nightly today. Unlocked, that would be every leaf command on every offline host, not two tests. Worth saying out loud in case you'd still rather have the smaller change; the fallback is the one that keeps both hosts working.

    Repro and measurements

    The mirror is stood up from the other side — the lock's URLs are pointed at a closed port, leaving the configured index as the only thing that can serve the three dependencies, and uv gets a cache directory of its own (a wheel already in the cache is served whatever URL the lock names):

    cp -r plugins/leaf /tmp/payload
    sed -i 's|https://files.pythonhosted.org/|http://127.0.0.1:1/|g' \
      /tmp/payload/skills/leaf/scripts/interact.py.lock
    UV_CACHE_DIR=$(mktemp -d) /tmp/payload/bin/leaf --help
    run cache configured index before after
    lock URLs reachable cold dead starts (fetches pythonhosted) starts
    lock URLs unreachable cold live fails, exit 1 starts
    lock URLs reachable warm dead starts starts

    That third row is the offline case (UV_FROZEN=1 UV_DEFAULT_INDEX=http://127.0.0.1:1/simple) — unchanged. The added uv sync --script probe costs 12–55ms warm, against ~480ms for the uv run behind it.

    One case the fallback can't serve: a read-only payload, since --upgrade writes the lock. uv says so plainly (failed to write to file … Permission denied), and no leaf install I can find is read-only, so there's no guard for it.

  3. added a commit that references this issue on Aug 20, 2026
    0092ac3
  4. added a commit that references this issue on Aug 20, 2026
    be94852
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions