Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic: Resolution should contain all packages #2763

Closed
BradLucky opened this issue Apr 1, 2024 · 9 comments
Closed

Panic: Resolution should contain all packages #2763

BradLucky opened this issue Apr 1, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@BradLucky
Copy link

We are using uv in Github Actions to install our dependencies. It has been running great for a few weeks now until this afternoon (after 0.1.27 released). Using https://github.com/marketplace/actions/setup-uv, we did not have uv locked to a specific version, and it was unable to install dependencies, giving the error.

Running the command uv pip install --system -r requirements.txt produces the error:

Resolved 202 packages in 605ms
thread 'main' panicked at crates/uv/src/commands/pip_install.rs:670:18:
Resolution should contain all packages
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After a bit of research, I tried locking CI to version 0.1.26 and things worked fine.

Resolved 202 packages in 6.16s
Downloaded 3 packages in 94ms
Installed 3 packages in 11ms

Our CI runner OS is Ubuntu 22.04.4 LTS.

@zanieb
Copy link
Member

zanieb commented Apr 1, 2024

This sounds very likely to be a regression related to #2596

Can you share more details on the requirements? Do you have a minimal reproduction?

@zanieb zanieb added the bug Something isn't working label Apr 1, 2024
@charliermarsh
Copy link
Member

Or even a maximal reproduction :)

@charliermarsh
Copy link
Member

One reproduction is if you have multiple versions of a package installed. Then, the resolver will try to use them, but the install plan will reject them all.

uv venv --seed
source .venv/bin/activate
pip install anyio==3.7.0 --ignore-installed
pip install anyio==4.0.0 --ignore-installed
uv pip install anyio black --verbose

Yields:

thread 'main' panicked at crates/uv/src/commands/pip_install.rs:678:18:
Resolution should contain all packages
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@charliermarsh
Copy link
Member

In general, we probably need to try and reduce the coupling in the assumptions, hmm...

@bschoenmaeckers
Copy link
Contributor

bschoenmaeckers commented Apr 2, 2024

I got the same error on my local machine when installing the following minimal requirements.txt file:

--extra-index-url https://private-package-registry/simple
--extra-index-url https://download.pytorch.org/whl/cpu

torch==2.1.0+cpu
private-package==1.0.0  # Does not depend on torch
uv pip install -r requirements.txt
Resolved 47 packages in 330ms
thread 'main' panicked at crates\uv\src\commands\pip_install.rs:670:18:
Resolution should contain all packages
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@zanieb
Copy link
Member

zanieb commented Apr 2, 2024

@bschoenmaeckers are any of those packages already installed locally?

@zanieb
Copy link
Member

zanieb commented Apr 2, 2024

@bschoenmaeckers I cannot reproduce this:

❯ cat requirements.txt
--extra-index-url https://astral-sh.github.io/packse/0.3.8/simple-html/
--extra-index-url https://download.pytorch.org/whl/cpu

torch==2.1.0+cpu
example-a==1.0.0

❯ uv venv
Using Python 3.11.8 interpreter at: /usr/bin/python3
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate

❯ cargo run -- pip install -r requirements.txt
    Finished dev [unoptimized + debuginfo] target(s) in 0.16s
     Running `target/debug/uv pip install -r requirements.txt`
Resolved 11 packages in 558ms
Installed 11 packages in 860ms
 + example-a==1.0.0
 + example-b==2.0.0
 + filelock==3.9.0
 + fsspec==2023.4.0
 + jinja2==3.1.2
 + markupsafe==2.1.3
 + mpmath==1.3.0
 + networkx==3.2.1
 + sympy==1.12
 + torch==2.1.0+cpu
 + typing-extensions==4.8.0

@zanieb zanieb changed the title 0.1.27 breaks in Github Actions Panic: Resolution should contain all packages Apr 2, 2024
zanieb added a commit that referenced this issue Apr 2, 2024
…tion in the resolver (#2779)

Addresses panic introduced in #2596 and reported in
#2763 (comment)

When there are multiple versions of a package available, we remove the
existing packages before installing the resolved version to "fix" the
environment. We must remove all of the package versions and reinstall
because removing _any_ of the package versions could break the others.
Since reinstalls require a pull from the remote, this broke a contract
between the resolver and the planner which must always agree on which
packages should come from the remote. This further demonstrates that we
should be constructing the install plan with more concrete knowledge
from the resolver (i.e. `ResolvedDist` instead of `Requirement`) to
avoid having to manually ensure logic matches.

## Test plan

Fails on `main` with panic succeeds on branch

```
uv venv --seed
source .venv/bin/activate
pip install anyio==3.7.0 --ignore-installed
pip install anyio==4.0.0 --ignore-installed
cargo run -- pip install anyio black -v
```
@bschoenmaeckers
Copy link
Contributor

@bschoenmaeckers are any of those packages already installed locally?

I cannot reproduce this error anymore after creating a new venv. So it was maybe just a fluke.

@charliermarsh
Copy link
Member

I'm going to close for now since we've fixed a few issues here. If you see it again in the latest release, please LMK and we'll re-open!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants