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

Is pyenv activate supposed to be usable in noninteractive shells? #389

Open
native-api opened this issue May 26, 2021 · 2 comments
Open

Comments

@native-api
Copy link
Member

native-api commented May 26, 2021

In pyenv/pyenv#1914, a user was getting the Failed to activate virtualenv. Perhaps pyenv-virtualenv has not been loaded into your shell properly. message when trying to pyenv activate in a noninteractive shell.

OS: Debian Buster 10 (AWS / EC2)
Pyenv: 2.0
Pyenv-virtualenv: 1.1.5
Debug trace: pyenv/pyenv#1914 (comment)

Is pyenv activate supposed to be usable in this scenario?

  • If yes, Pyenv-virtualenv's -- and also Pyenv's -- documentation needs to be rewritten to install shell functions into both interactive and non-interactive shells -- including the case when the login shell and the running shell are different shells.
    • I'm not sure if this is a good idea: it's going to be disruptive, requiring stuff like setting BASH_ENV and creating a new script file.
  • If no, the error message needs to be fixed to not read like a configuration error but instead instruct the user to source the activation script directly or something.
@native-api native-api changed the title Is pyenv activate supposed to be usable in noninterative shells? Is pyenv activate supposed to be usable in noninteractive shells? May 26, 2021
@FCamborda
Copy link

I find this rather interesting. I'm trying to set up a Docker image where pyenv is available and usable (for both production and development purposes), and it would be interesting to know what the maintainers have to say here.

@native-api
Copy link
Member Author

native-api commented Feb 14, 2024

Well, I'm the (main active) maintainer now.

From what I can see in the codebase, Pyenv has never loaded, or it's documentation suggested to load by default, shell integration into noninteractive shells. Probably because that's prone to breaking scripts.

So if you need commands like activate that need shell integration, in noninteractive shells, you need to run the necessary init commands manually or change shell startup files accordingly.

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

No branches or pull requests

2 participants