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

Allow choosing the first virtual environment that's found #45

Open
steve-marmalade opened this issue Feb 18, 2025 · 3 comments
Open

Allow choosing the first virtual environment that's found #45

steve-marmalade opened this issue Feb 18, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@steve-marmalade
Copy link

Thank you for this helpful utility!

In the case that more than one virtual environment is found, it would be nice to have an option (maybe via --first or --auto) so that it runs with the first environment it discovers, rather than having to specify the venv manually.

@guludo guludo added the enhancement New feature or request label Mar 7, 2025
@guludo
Copy link
Owner

guludo commented Mar 7, 2025

Could you elaborate more on your use-case?

I'm not sure about adding a --first option. There is no explicit sorting criteria for the list of environments found, so I'm not sure adding an option relying on the order of environments is the best approach here.

@guludo
Copy link
Owner

guludo commented Mar 7, 2025

Maybe this next comment bit off-topic and deserves an issue of its own, but nevertheless related: I guess we could try to think of ways of teaching venv-run to disambiguate and select the desired env for the user. Some approaches I can think of:

  • Use the most recent environment, i.e., the one that was created last;
  • Use the most recently used environment, i.e., the one that was last used via venv-run.

Both could be implemented and enabled via CLI flags.

@steve-marmalade
Copy link
Author

steve-marmalade commented Mar 7, 2025

Hey @guludo ! Thanks for following up.

Here's the behavior that led me to create the issue:

$ pipx run -q venv-run nvim
More than one virtual environment found:
  /home/path/to/my/directory/venv
  /home/steve/.pyenv/versions/3.11.6
Please, use the --venv option.

And my desire is to have venv-run "do the right thing" which is choose the correct virtualenv. In this case, the first virtualenv is the one I want, which is why I submitted such an opinionated suggestion. But taking a step back, perhaps we could add to your proposed list of heuristics: prioritizing a virtualenv that is closer (in the filesystem) to the command being run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants