Open glondu opened 2 years ago
Would setting OPAMSWITCH
– automatically added when calling eval $(opam env --set-switch)
– work as a temporary workaround in your case?
OPAMROOT
only sets the "global working directory" for opam so it’s rather unrelated to switches in general,
and OPAM_SWITCH_PREFIX
is a little different from OPAMSWITCH
: it shows the path to the global switch you currently have set in the environment, but opam itself might detect that you’re currently in a local switch and override that variable for its execution (switching to a local switch is automatic so that’s why you’re seeing all those checks for _opam
directories).
Now, I'm not sure what could be improved more systematically here. We could add an option to disable the automatic local switch detection but it introduces other issues that might be worse for usability. We can't just lookup at the list of local switches already added either because opam supports the automatic import of local switches too. Does anyone have an idea?
Would setting
OPAMSWITCH
– automatically added when callingeval $(opam env --set-switch)
– work as a temporary workaround in your case?
I found another workaround (autofs-specific) in the meantime. But setting OPAMSWITCH
seems to disable the annoying behaviour indeed.
Now, I'm not sure what could be improved more systematically here. We could add an option to disable the automatic local switch detection but it introduces other issues that might be worse for usability. We can't just lookup at the list of local switches already added either because opam supports the automatic import of local switches too. Does anyone have an idea?
Maybe not cross filesystem boundaries when looking for _opam
?
Starting a few months back (I don't know exactly what triggered this), my development environment (which uses Opam (but no
_opam
) + Dune + Emacs + Merlin) started to freeze regularly (and annoyingly) and it took me time to figure out what was happening.It turns out that commands like
opam var bin
look for a directory named_opam
in all directories up to/
, and the lookup at some level is slow (a few seconds) because of a network filesystem. However, in my environment,OPAMROOT
andOPAM_SWITCH_PREFIX
are set, so there should be no need to look for_opam
.Is there a way to disable this behaviour?