-
-
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
Update shell configuration info in README #1359
Conversation
- `~/.bash_profile` may not be sourced in desktop environment. When this happenes, `~/.profile` can be used instead. - The `pyenv` function should be exported if `eval $(pyenv init -)` is put into `~/.profile` or `~/.bash_profile`.
Thanks! I would be more specific about when to use |
My thought is when put |
My thought is shell configuration schemes are a mess and that has a lot to do with why users so often have broken environments or are confused about their setup. While the invocation section of shell man pages seem carefully written enough, there is no explanation of the requirements driving the complexity.
The only case for different shell configurations I know of is interactive or non-interactive; so, I source .profile from .bashrc, then in .profile I use a conditional return if non-interactive, I use additional branches within that file to detect OS, installed software and the specific shell, so aliases, functions and environmental configurations only get set when appropriate. I source ~/.profile from all of my shell rc files (zsh, ksh, bash, etc) to keep all of my configuration in one file. That file checks if it is sourced from a non-interactive shell and returns without error if so, which keeps scp (and anything else using the shell programmatically) from breaking. The thing to keep in mind is shell environment setup is not by design, it's by evolution. There probably isn't a good answer for everyone today. I like the idea of exporting functions from profile, it works when you use run control (rc) files for run control and profile for interactive function setup, as best I can tell. For me, I'll source my .profile from run control (rc files) and do my best to test the environment before setting anything that isn't universal (eg, only set zsh features in zsh, etc). As for what is best in pyenv docs, not sure, but I would avoid anything like 'you may need' in documentation or instructions about what you actually need. Better to state the circumstances you can think of, eg
Nobody wants to be definitive about how anybody in the world should always setup their system, and there is usually more than one solution. But if you explain how to deal with the specific problem cases you can think of, that's good documentation and the elucidation sometimes identifies a better coding solution too. BTW - my favorite shell is ksh but the good version is only available on NetBSD, so I usually use bash on Mac and Linux. |
It's updated.And thank @georgalis for sharing your setup! It makes a lot of sense,, and maybe I should do it in the same way. |
Would be great to get this via rbenv's (upstream) README: https://github.com/rbenv/rbenv/blob/master/README.md There are changes in this regard IIRC, so it would be good to not derive further from it, but get it straight via/from there. |
|
||
If you put this in the run control file (like `~/.bashrc`), this will work fine; otherwise (like if you | ||
use `~/.bash_profile` or `~/.profile` instead, and it is not sourced in `~/.bashrc`), you need to put | ||
`export -f pyenv` after this to access the function from a sub-shell. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should/could export -f pyenv
instead somehow be part of pyenv init -
? That would avoid adding any extra steps for users to do.
Perhaps somewhere inside this block:
Lines 138 to 154 in 7097f82
if [ "$shell" != "fish" ]; then | |
IFS="|" | |
cat <<EOS | |
command="\${1:-}" | |
if [ "\$#" -gt 0 ]; then | |
shift | |
fi | |
case "\$command" in | |
${commands[*]}) | |
eval "\$(pyenv "sh-\$command" "\$@")";; | |
*) | |
command pyenv "\$command" "\$@";; | |
esac | |
} | |
EOS | |
fi |
(FWIW, I found this PR via #1347. I was having the same issue with sub-shells and your suggestion there fixed things for me. Thanks!)
Superseded by #1920 |
~/.bash_profile
may not be sourced in desktop environment. When this happenes,~/.profile
can be used instead.pyenv
function should be exported ifeval $(pyenv init -)
is put into~/.profile
or~/.bash_profile
.