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

poetry env use and poetry env remove are not working #9924

Open
anmol-aidora opened this issue Dec 27, 2024 · 1 comment
Open

poetry env use and poetry env remove are not working #9924

anmol-aidora opened this issue Dec 27, 2024 · 1 comment
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@anmol-aidora
Copy link

anmol-aidora commented Dec 27, 2024

Description

I have created two virtual environments using venv in my repository. There are two different sets of dependencies I need to work with for different branches of the code.

The first virtual environment is created by default. But when I try to switch to the other one (.venv_2), it doesn't raise any error but doesn't change the environment as well:


poetry env info

Output:

Virtualenv
Python:         3.12.2
Implementation: CPython
Path:           /path/to/project/.venv
Executable:     /path/to/project/.venv/bin/python
Valid:          True

Base
Platform:   darwin
OS:         posix
Python:     3.12.2
Path:       /path/to/python/versions/3.12.2
Executable: /path/to/python/versions/3.12.2/bin/python3.12

poetry env use  /path/to/project/.venv_2/bin/python

Output:

Using virtualenv:  /path/to/project/.venv # Wrong! It should have been using `.venv_2`, but it's not.

Also, poetry env remove is not working too:

poetry env remove /path/to/project/.venv/bin/python

Output:

Env .venv doesn't belong to this project.

Workarounds

No workaround! Right now I have to delete the .venv and recreate it every time I switch my branches.

Poetry Installation Method

pipx

Operating System

Macos

Poetry Version

Poetry (version 1.8.5)

Poetry Configuration

cache-dir = ".../Library/Caches/pypoetry"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
solver.lazy-wheel = true
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = true
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # .../Library/Caches/pypoetry/virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true

Python Sysconfig

Not attaching as it reveals personal details

Example pyproject.toml

No response

Poetry Runtime Logs

Loading configuration file .../Library/Application Support/pypoetry/config.toml
Loading configuration file .../poetry.toml
Using virtualenv: .../.venv
@anmol-aidora anmol-aidora added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Dec 27, 2024
@dimbleby
Copy link
Contributor

I have created two virtual environments using venv in my repository...

You have misunderstood what the poetry env commands do - please read the docs. Perhaps virtualenvs.prefer-active-python is what you are after.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants