Use opam depext to install all deps in a .opam file?

I’m trying to use opam depext, but it seems to have a chicken-and-egg problem:

  • opam depext alone will only install dependencies for installed packages
  • I can’t install those packages because I’m missing the OS dependencies

It seems like I can work around this by using the opam depext [list of packages] form, but then I have to repeat all of my packages instead of just using my .opam file.

Am I missing something here?

opam install --deps-only . will install all dependencies defined in the opam file in the current directory (you can also set the opam file as an explicit target). I’d think that depext should work in the same way. Whether it actually does, that I’m not sure of.

EDIT: I’m only talking about opam 2.0 here. I’ve long forgotten the details of 1.2.2

1 Like

The key here is to pin.

$ opam pin add -yn your_project .         # will make your_project visible to opam
$ opam depext your_project                # will install all OS deps of your deps
$ opam install --deps-only your_project   # will install your deps 

All these commands should read your .opam file. That’s what I use for my Dockerfile.

2 Likes

That worked, thanks! I was trying to do opam depext when I needed to do opam depext my_project.