Sync versions of several packages coming from a single repo


Let’s suppose I have a repository compiled with jbuilder and released with topkg that generates two opam packages x and a dependent package x-y. In x-y.opam, I have the dependency:

depends: [

However, this is a problem because x-y version σ depends on the same version of x (for security because it uses internal APIs which may evolve more quickly than the external one). Is there a way to automatically have

depends: [
  "x" {= "σ"}

when submitting the package? I tried "x" {= "%%VERSION%%"} but it does not work and would be problematic with pinned packages anyway. What is the recommended way of doing this with topkg?


With opam v2 you can access the name and version of the current package via _:name and _:version variables but I highly suspect you are not allowed to use these in version constraints.

opam2 has computed dependencies which do this: please see


Yes, opam 2 supports this case: see

Note that I actually looked for this in opam v2’s documentation and found nothing. It would be nice to have it there rather than in a blog post.

It’s probably not explicit enough, but the documentation is actually up-to-date:

1 Like

Sorry my bad, I was looking at where this should probably be mentioned/linked from.