-
Notifications
You must be signed in to change notification settings - Fork 365
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
opam init advises misconfiguring shell startup scripts #4201
Comments
I was just about to report this issue! Login shells load the first file (in that order) of Bash documentation states that:
|
Thanks for reporting. Bash init is a mess ;) The solutions often seems simple, but the practice always shows different... E.g. initially we had been using IIRC, the choice of On the specific message
We really want to keep the automatic modifications to the strict minimum, i.e. one line in one file. We could check in the scripts whether they were run as login or not, but due to the above, we probably don't even want to. |
Luckily, I have no illusion things are simple. And I'm afraid some requirements will have to go.
EDIT: so I'd drop at least "only change one file". |
For the Bash case, if following the flowchart here I’d suggest patching the first file of |
But many of those settings are not exported (because they involve functions or special settings), so they don't belong to any profile files, but into .bashrc. I expect trying to export PROMPT_COMMAND might break other .profile scripts, such as iterm2 integration, which call non-exported functions. And exporting functions seems a bash-only extension... (Edit: there seems be other ways in other shells, they don't seem portable - see https://stackoverflow.com/a/1886397/53974). |
opam outputs
But that's backwards. As also mentioned in this old opam issue, a typical setup is that:
~/.bashrc
~/.profile
— and usually that sources.bashrc
(the opposite of what opam advises). For instance, on DebianThe rationale is that environment variables are set by login shells loading
~/.profile
and inherited by other shells — while other settings that are not inherited belong in~/.bashrc
, which ends up loaded by all shells.The recommended setup would load
~/.profile
multiple times, which is unexpected for lots of initialization code.This bug is described in #3304 — the message comes from https://github.com/ocaml/opam/pull/3304/files#diff-234457b80298a00240e5fcd7591e5432R603.
Here's my proposed fix:
~/.opam/opam-init/variables.sh
in~/.profile
~/.opam/opam-init/env_hook.sh
in~/.bashrc
The text was updated successfully, but these errors were encountered: