ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.24k stars 353 forks source link

Opam shouldn't always preprend itself to the `PATH` #5937

Closed MisterDA closed 5 months ago

MisterDA commented 5 months ago

I'm using opam 2.2.0\~beta2\~dev (bd96d2ae56a17656e607a68ceb85e3d13594c14a) and zsh 5.9 on Fedora 40. opam has updated my ~/.zshrc with its scripts. Each time I get a new prompt, opam puts itself at the beginning of the PATH. This is a bit counter-intuitive and annoying: I sometimes install an OCaml compiler to a random location, without going through opam, just to test how it behaves when installed, and now I'm unable to override my PATH.

$ echo $PATH
/home/antonin/.opam/default/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
$ export PATH="xxx:$PATH"
$ echo $PATH             
/home/antonin/.opam/default/bin:xxx:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin

Maybe I could configure the zsh script to use opam env --inplace-path?

dra27 commented 5 months ago

I don't think this is new to 2.2, right - a long time ago, I think you agreed for opam init to install a hook to do that?

MisterDA commented 5 months ago

Probably, yes. Let's say I'll close this, and next time I don't understand what's happening I'll find this issue again ;)