Set/override `os-distribution`

Hi !
On my system, I have both brew and port installed, and sometimes, I have libraries present in both of them. For example I have the gmp library installed in both of them, so when I install zarith, the detection will select the library from brew (my understanding is that brew is always checked first).

Is it possible to by-pass this and make opam select the library in port instead ? Maybe by setting or overriding manually os-distribution ? At the moment, I have to temporarily “hide” homebrew from opam while I install zarith to make it choose the right library.

You are asking for trouble.

You might succeed by setting up the C toolchain LIBRARY_PATH and C_INCLUDE_PATH environment variables appropriately before installing (or if gmp uses pkg-config, the PKG_CONFIG_PATH variable).

Not by choice I assure you :slight_smile:

Do you mean that by setting these I could prevent opam to use the os-distribution variable ?

No you could make it lookup the right library.

This is possible with the (hopefully) soon to be released opam 2.2.0. See:

You just need to be careful to change both os-family and os-distribution:

opam var --global os-distribution=macports
opam var --global os-family=macports

You can install opam master fairly easily by compiling it from source:

git clone https://github.com/ocaml/opam
cd opam
make cold
sudo install ./opam /usr/local/bin/opam 

make cold does everything for you and does not require you to install any of opam’s dependencies.

3 Likes