tweag / opam-nix

Turn opam-based OCaml projects into Nix derivations
MIT License
111 stars 33 forks source link

Unable to verify version bounds for a pin-depend #13

Closed ralsei closed 2 years ago

ralsei commented 2 years ago

Describe the bug When placing version bounds in depends as well as having a pin-depend for the same dependency, opam-nix (or its call to OPAM) fails to verify that the package is of the correct version (despite running OPAM manually succeeding):

error: builder for '/nix/store/9rlbv11lhf3ghpxdyclr1f2x2n0mxy47-resolve.drv' failed with exit code 20;
       last 5 log lines:
       > [ERROR] No solution including optional dependencies for cooltt.0.0 & ocaml-base-compiler:   * Missing dependency:
       >             - bantorra < 0.2
       >             no matching version
       >
       >

To Reproduce flake.nix is exactly the same as in #12.

cooltt.opam (different):

opam-version: "2.0"
name: "cooltt"
version: "0.0"
maintainer: "Jonathan Sterling <jmsterli@cs.cmu.edu>"
authors: ["The RedPRL Development Team"]
homepage: "https://github.com/RedPRL/cooltt"
bug-reports: "https://github.com/RedPRL/cooltt/issues"
dev-repo: "git+https://github.com/RedPRL/cooltt.git"
synopsis: "Experimental implementation of Cartesian cubical type theory"
license: "Apache-2.0"
depends: [
  "dune" {>= "2.0"}
  "ocaml" {>= "4.10.0"}
  "ppx_deriving" {>= "4.4.1"}
  "bantorra" {>= "0.1" & < "0.2"}
  "bwd" {>= "1.2"}
  "cmdliner" {>= "1.1"}
  "containers" {>= "3.4"}
  "ezjsonm" {>= "1.2.0"}
  "menhir" {>= "20180703"}
  "uuseg" {>= "12.0.0"}
  "uutf" {>= "1.0.2"}
  "yuujinchou" {>= "2.0.0" & < "3"}
  "odoc" {with-doc}
  "kado"
]
pin-depends: [
  [ "kado.~dev" "git+https://github.com/RedPRL/kado" ]
  [ "bantorra.0.1.0" "git+https://github.com/RedPRL/bantorra#1e78633d9a2ef7104552a24585bb8bea36d4117b" ]
]
build: [
  ["dune" "build" "-p" name "-j" jobs]
  ["dune" "build" "-p" name "-j" jobs "@runtest"] {with-test}
  ["dune" "build" "-p" name "-j" jobs "@doc"] {with-doc}
]

Expected behavior It should find the package and build normally.

Environment

balsoft commented 2 years ago

https://github.com/RedPRL/bantorra/blob/1e78633d9a2ef7104552a24585bb8bea36d4117b/bantorra.opam doesn't specify its version in any way, so opam-nix resorts to adding it as packages/bantorra/bantorra.dev. I wonder how opam deals with this when "building manually". Could you provide some example commands which work for you?

balsoft commented 2 years ago

As a workaround, you can either

  1. Specify version in the bantorra.opam package
  2. Remove the constraint (I know this is not great, but I don't understand how opam handles this here anyways)
balsoft commented 2 years ago

Ah, sorry, I just realised that the version is specified right there in pin-depends :facepalm:. I'll fix this.

balsoft commented 2 years ago

Please check if this is fixed :)

balsoft commented 2 years ago

Whoops, sorry, the first commit was broken. This one should be better.

ralsei commented 2 years ago

Works fine, thanks!