-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 putting "eval "$(pyenv init -)"" in ~/.bash_profile really a good suggestion? #1347
Comments
Good observation about all the different ways to bootstrap your environment! I've supported many shells (bash, bourne, zsh, ksh, ash, etc) on different OS (Linux, BSD, Darwin) at different sites. I've also created a tool set of command line functions and aliases. Getting your shell all setup with tuned and bug free preferences can take forever and a week and it's the last thing you want to fix when you've got other work to do. When users ask for help they generally don't want you refactoring their multiple shell conf files either. Here's the standard I use when I'm setting up a system or my own accounts. All of my functions and aliases go into .profile (including all the stuff that has been added to user's bashrc, bash_profile, etc). In .profile, I use bourne compatible scripting to determine the OS, shell, and installed programs, with conditionals to set only appropriate environment, being careful to branch early for non interactive shells (so ssh works as expected) ...os and shells specific aliases and functions...
This way I can keep a standard .profile that can be freely updated, @AmaiKinono I don't think there is a good answer about where to set your environment to use pyenv, because it depends on the system and the user. Users have to maintain their environment and there are a lot of systems and standards to choose from. It might be better to just instruct users what to put in their environment, if you want to submit a patch for the docs, but I would close this issue in any event. :) Thanks for the tip on exporting functions! |
I have created a PR (#1359), please see if the changes are reasonable. |
It's suggested in README.md to put
eval "$(pyenv init -)"
(and environment variables) in~/.bash_profile
, which may be not reasonable.I am a (manjaro) Linux user. As far as I am concerned,
~/.bash_profile
is not sourced when logging in under X (which means, under a graphical environment). Here's a little experiment:export USING_TTY=1
in~/.bash_profile
, reboot the computer.$ echo $USING_TTY
, nothing is printed.$ echo $USING_TTY
, "1" is printed.Most desktop environments sources
~/.profile
when logging in, so that should be the right place for Linux users to put environment variables andeval $(pyenv init -)
in. When using text tty, only~/.bash_profile
is sourced, but it's a common practice to source~/.profile
and~/.bashrc
inside~/.bash_profile
, so this would make pyenv works both on desktop environment and text tty.Please tell me if I am wrong.
Btw, here's a little problem. I myself put these in
~/.profile
, and most of the functionalities work well under a desktop environment.$ which python
gives me~/.pyenv/shims/python
, which should be a sign that I'm doing it right, but$ pyenv shell
givespyenv: shell integration not enabled. Run 'pyenv init' for instructions.
. Does anybody know why this happens?Update: I found I have to put
export -f pyenv
aftereval "$(pyenv init -)"
to export the function for sub-shells to use. This fixes the above problem.The text was updated successfully, but these errors were encountered: