Cross compile and opam lock files with conflicting dependencies

I am working on an Apple Silicon MacOS
I would like to compile/allow the project to be compiled on amd64 Debian

The way I do it is:

  • I create a dockerfile and copy all files
  • then install the dependencies from the lockfile:
opam install --yes --deps-only --locked -- .
  • finally build the project

Unfortunately the lockfile has a depdency on host-arch-arm64, which while useful if you open the project on arm machines causes the whole installation to fail on amd64.

Is there a built-in way to install opam dependencies ignoring specific dependencies (host-arch-arm64)?

--best-effort works, but I am hoping for something more targeted:

opam install --yes --deps-only --locked --best-effort -- .

A workaround was merged in opam-repository just 2 days ago for this problem (see ocaml/opam-repository#27302 and ocaml/opam#6042). A simple opam update should fix this

2 Likes