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

uv pip install --target flags says to add --system #9356

Closed
PatrickAlphaC opened this issue Nov 22, 2024 · 3 comments · Fixed by #9371
Closed

uv pip install --target flags says to add --system #9356

PatrickAlphaC opened this issue Nov 22, 2024 · 3 comments · Fixed by #9371
Assignees
Labels
bug Something isn't working error messages Messaging when something goes wrong

Comments

@PatrickAlphaC
Copy link

Running the following:

uv pip install requests --target ./

Results in:

error: No virtual environment found; run `uv venv` to create an environment, or pass `--system` to install into a non-virtual environment

However, I think this is incorrect. I am giving the pip install a target so it shouldn't want to be installed with --system?

@ReinforcedKnowledge
Copy link
Contributor

ReinforcedKnowledge commented Nov 22, 2024

If I may add on your issue:

uv init --package try_pip_install_target
cd try_pip_install_target
uv add numpy
cd ..
uv pip install --target try_pip_install_target requests

Gives the same error.

error: No virtual environment found; run `uv venv` to create an environment, or pass `--system` to install into a non-virtual environment

But:

cd try_pip_install_target
uv pip install --target ./ requests

Works.

So doing uv pip install --target <target-path> where <target-path> is a sub-directory or unrelated directory won't work even if that directory contains a venv. But doing it inside a directory that contains a venv works.

So either the command was not designed to mirror pip install and in that case maybe the documentation is not clear enough, and I guess in that case, probably, this is a command made for workspaces.

Or it was designed to mirror pip install but doesn't work correctly.

Or I'm misunderstanding some subtle detail 😅

@charliermarsh charliermarsh added bug Something isn't working error messages Messaging when something goes wrong labels Nov 22, 2024
@charliermarsh
Copy link
Member

I need to refresh my memory here, but I agree that at minimum it's confusing.

@charliermarsh
Copy link
Member

This has come up enough times that I'll look into changing it:

@charliermarsh charliermarsh self-assigned this Nov 22, 2024
charliermarsh added a commit that referenced this issue Nov 22, 2024
## Summary

If we're installing with `--target` or `--prefix`, then it's not a
mutable operation, so we should be allowed to discover system Pythons. I
suspect this was hard to special-case in the past but is now trivial
after @zanieb's various refactors.

Closes #9356.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working error messages Messaging when something goes wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants