opam
opam copied to clipboard
Silence env hooks errors
In some cases (such as when using opam-nix+direnv), we are in a shell with the env hook enabled but opam has been replaced by a dummy binary.
In this situation, eval $(opam env) will fail, which is expected. However, it will output annoying errors each time the hook is loaded. I think errors in the hook should always be silenced.
Is there no way for you to instead make the dummy binary output nothing on stdout instead?
The binary is out of my control in this case, but if silencing the errors is not a solution, then I could try to wrap it inside another in my control, although that would be very hacky in my case.
I'll let you make the call :)
We discussed this further today - the decision's not to go with this change. On the one hand, if something does go wrong with stock opam, the user is necessarily spammed with error messages on the console until the issue is resolved. On the other hand, if something has gone wrong, the non-advanced user may be left with no clue as to why the environment isn't being set correctly.
It's especially strange in this case where the only use-case given so far for ignoring errors is to allow for a shim of the opam command to be ignored (i.e. we're altering a script in opam to work around a problem caused by just part of opam being altered by something else).
It makes sense, thank you for the feedback!