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.21k stars 348 forks source link

lock hold/release messages as part of another command should be printed on stderr #5990

Closed Khady closed 1 month ago

Khady commented 1 month ago

information messages such as "Another process has locked" and "lock acquired" should be printed on stderr, not stdout, as they aren't really part of the output of a command.

An example where we caught the problem

opam switch set-invariant --packages=ahrefs-setup,ahrefs-dev-tools-deps,ocaml-base-compiler.$(opam show ocaml-base-compiler --field=installed-version),ahrefs-all-deps

Can end up being executed as

opam switch set-invariant --packages=ahrefs-setup,ahrefs-dev-tools-deps,ocaml-base-compiler.Another process has locked /home/user/monorepo/.opam/repo/state-11ABC690.cache, waiting (C-c to abort)... lock acquired. 4.14.0,ahrefs-all-deps

This is true for lock messages but probably also applied to other informational messages.

kit-ty-kate commented 1 month ago

Will be fixed by https://github.com/ocaml/opam/pull/5999

kit-ty-kate commented 1 month ago

In the meantime, i believe that if you add --readonly to your opam show invocation it should now work fine without waiting for the lock.

rr0gi commented 1 month ago

are there cases when opam show is not readonly?

kit-ty-kate commented 1 month ago

Yes, for example, if the internal repository data cache (marshalled data) isn't up-to-date or has been removed, opam will try to save that file by default