Skip to content

uv pip install unexpectedly works against unsourced environment in ~/.local/ #15923

Description

@dvrogozh

Summary

I was experimenting with installation options which uv provides and came across the following scenario which seems quote confusing. It occurs that if uv virtual environment is created in ~/.local/ folder, then some of the uv pip commands, specifically - uv pip install - start to pick it up even if environment is not activated while other commands, such as uv pip show and uv pip list ignore it.

Can either the whole this behavior be prohibited entirely (uv pip install to be failed) or allowed and then all the uv commands should support such scenario?

docker run -it --rm ubuntu:24.04
root@b7d54f53e6ef:/# apt-get update && apt-get install curl
root@b7d54f53e6ef:/# curl -LsSf https://astral.sh/uv/install.sh | sh
downloading uv 0.8.18 x86_64-unknown-linux-gnu
no checksums to verify
installing to /root/.local/bin
  uv
  uvx
everything's installed!

To add $HOME/.local/bin to your PATH, either restart your shell or run:

    source $HOME/.local/bin/env (sh, bash, zsh)
    source $HOME/.local/bin/env.fish (fish)
root@b7d54f53e6ef:/# source $HOME/.local/bin/env

root@b7d54f53e6ef:/# uv pip install numpy
error: No virtual environment found; run `uv venv` to create an environment, or pass `--system` to install into a non-virtual environment

root@b7d54f53e6ef:/# uv venv --allow-existing $HOME/.local
Using CPython 3.13.7
Creating virtual environment at: /root/.local
Activate with: source root/.local/bin/activate

root@b7d54f53e6ef:/# uv pip install numpy
Using Python 3.13.7 environment at: /root/.local
Resolved 1 package in 111ms
Prepared 1 package in 385ms
Installed 1 package in 61ms
 + numpy==2.3.3

root@b7d54f53e6ef:/# uv pip show numpy
Using Python 3.13.7 environment at: /root/.local/share/uv/python/cpython-3.13.7-linux-x86_64-gnu
warning: Package(s) not found for: numpy

root@b7d54f53e6ef:/# uv pip list
Using Python 3.13.7 environment at: /root/.local/share/uv/python/cpython-3.13.7-linux-x86_64-gnu
Package Version
------- -------
pip     24.3.1

Platform

Ubuntu 24.04

Version

0.8.18

Python version

Python 3.13.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAsking for clarification or support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions