I think it would be good to patch the opam-repository otherwise people are constantly going to run into this.
Indeed, and I bumped into the same issue (needing 4.07.1 in order to compile a version of coq compatible with the official macos package).
I made a pull request on opam:
Thanks for fixing this! However, https://github.com/ocaml/opam/issues/4448 suggests that a few functions are still broken, including
getgroups, and that’s breaking opam master. I assume that should be fixed in a similar way?