opam icon indicating copy to clipboard operation
opam copied to clipboard

Silence env hooks errors

Open Firobe opened this issue 3 years ago • 1 comments

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.

Firobe avatar Aug 23 '22 22:08 Firobe

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 :)

Firobe avatar Aug 29 '22 14:08 Firobe

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).

dra27 avatar Jan 23 '23 15:01 dra27

It makes sense, thank you for the feedback!

Firobe avatar Jan 23 '23 16:01 Firobe