-
Notifications
You must be signed in to change notification settings - Fork 360
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
Multiple switches in PATH after logout #5761
Comments
what version of opam do you have? |
2.1.5, it's a fresh install with the script on opam (https://opam.ocaml.org/doc/Install.html#Binary-distribution). |
Could you try using the latest 2.2.0~alpha3 release just in case? (don’t worry it’s very stable, the only reason it’s an alpha verison is that the Windows support is not completed)
|
Just did that, and it doesn't solve it, sorry. |
Can you share the OPAM* variables status before calling init scripts? You can have that by adding something like |
Could you also try to replace |
related to #4649 |
With this in my config.fish: # opam debugging
set debug_file_name "$HOME/opam_debug.txt"
echo "$(date)" >>$debug_file_name
env | rg opam >>$debug_file_name After a reboot, I get this: mer. 20 déc. 2023 10:42:59 CET # This was from the login shell, which isn't interactive
mer. 20 déc. 2023 10:43:03 CET # Shell manually started:
PATH=<a whole lot of personal stuff>:~/.local/bin:~/.cargo/bin:~/.opam/standard/bin:/usr/local/sbin:<more personal stuff>
OPAM_SWITCH_PREFIX=~/.opam/standard
OCAML_TOPLEVEL_PATH=~/.opam/standard/lib/toplevel
CAML_LD_LIBRARY_PATH=~/.opam/standard/lib/stublibs:~/.opam/standard/lib/ocaml/stublibs:~/.opam/standard/lib/ocaml
# Changed 'isatty' to 'status 'is-interactive' in ~/.opam/opam-init/init.fish
# and rebooted
mer. 20 déc. 2023 10:56:13 CET # login again
mer. 20 déc. 2023 10:57:02 CET # manual shell again
[exact same thing as the big one above]
# Here I did 'opam switch fmt', and logged out (not a reboot) and logged back in
mer. 20 déc. 2023 10:58:23 CET
[exact same thing as the big one again]
mer. 20 déc. 2023 10:58:33 CET # Two opam switches! vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
PATH=<a whole lot of personal stuff>:~/.local/bin:~/.cargo/bin:~/.opam/fmt/bin:~/.opam/standard/bin:/usr/local/sbin:<more personal stuff>
OPAM_SWITCH_PREFIX=~/.opam/fmt
OCAML_TOPLEVEL_PATH=~/.opam/fmt/lib/toplevel
CAML_LD_LIBRARY_PATH=~/.opam/fmt/lib/stublibs:~/.opam/fmt/lib/ocaml/stublibs:~/.opam/fmt/lib/ocaml
# Here I did 'opam switch coq', and logged out/in again
mer. 20 déc. 2023 11:37:20 CET
# Same thing as right above, but interestingly it's not in the same order???
CAML_LD_LIBRARY_PATH=~/.opam/fmt/lib/stublibs:~/.opam/fmt/lib/ocaml/stublibs:~/.opam/fmt/lib/ocaml
OCAML_TOPLEVEL_PATH=~/.opam/fmt/lib/toplevel
OPAM_SWITCH_PREFIX=~/.opam/fmt
PATH=<a whole lot of personal stuff>:~/.local/bin:~/.cargo/bin:~/.opam/fmt/bin:~/.opam/standard/bin:/usr/local/sbin:<more personal stuff>
mer. 20 déc. 2023 11:37:25 CET # Three opam switches!
PATH=<a whole lot of personal stuff>:~/.local/bin:~/.cargo/bin:~/.opam/coq/bin:~/.opam/fmt/bin:~/.opam/standard/bin:/usr/local/sbin:<more personal stuff>
OPAM_SWITCH_PREFIX=~/.opam/coq
OCAML_TOPLEVEL_PATH=~/.opam/coq/lib/toplevel
CAML_LD_LIBRARY_PATH=~/.opam/coq/lib/stublibs:~/.opam/coq/lib/ocaml/stublibs:~/.opam/coq/lib/ocaml |
Adding more context as I dive deeper into this: # opam debugging
set debug_file_name "$HOME/dumpfile"
echo >>$debug_file_name
if status is-login
echo "This is a login shell" >>$debug_file_name
else if status is-interactive
echo "This is an interactive shell" >>$debug_file_name
else
echo "This is neither an interactive nor a login shell" >>$debug_file_name
end
env | rg opam >>$debug_file_name At the time of last startup/login, my global switch was
In my new terminal: > opam switch show
fmt
> echo $PATH
~/.opam/fmt/bin [A] ~/.opam/coq/bin [B]
> opam env
[...]
set -gx PATH ~/.opam/fmt/bin [A] ~/.opam/coq/bin [B] So I assume something has gone wrong before the interactive shells started (otherwise we'd have echo "hello" | fish 2>/dev/null
## in dumpfile
This is neither an interactive nor a login shell
PATH=[A]:~/.opam/fmt/bin:~/.opam/coq/bin:[B]
OPAM_SWITCH_PREFIX=~/.opam/fmt
MANPATH=~/.opam/fmt/man #Oh that's new!
> echo "env | rg opam" | fish >other_file
## in dumpfile (NOT other_file)
[exact same thing as above, with the same hash in OPAM_LAST_ENV]
## in other_file
PATH=~/.opam/fmt/bin:[A]:~/.opam/fmt/bin:~/.opam/coq/bin:[B] # Oh a triple!
OPAM_SWITCH_PREFIX=~/.opam/fmt
MANPATH=~/.opam/fmt/man:~/.opam/fmt/man #??????? Any ideas about where this could come from? |
To me the most surprising bit is here. From what I remember from your config.fish the opam specific bit is at the end, however stuff that you do before (all the stuff abbreviated as A) appears prepended which makes no sense to me if it's done before. Does fish do things in a delayed manner when you use Also, from a quick experiment, i can see that opam modifies the PATH to always put it at the top. Maybe there is something else trying to do the same? |
Was this fixed by #5866 ? |
Indeed! |
How to have multiple opam switches in your PATH at the same time
opam init
(so you havesource ~/.opam/opam-init/init.fish
in.config/fish/config.fish
). The second question (about the env-hook) doesn't seem to matter.~/.opam/foo/bin
in your PATH at this point.opam switch bar
. You obviously should have~/.opam/bar/bin
in your PATH, but you'll also see~/.opam/foo/bin
. Note that in my scenario they are not side by side, but in different part of the PATH (the 'correct' one being leftmost, with the other one in the middle). YMMV.bar
, thenbaz
...The text was updated successfully, but these errors were encountered: