How to pin a development repo in an opam file?

What is the proper way to pin the development repository of a package in an Opam file?

pin-depends: [ "fit" "git+" ]
error  3: File format error in 'pin-depends' at line 14, column 15: while expecting versioned package: OpamPackage.of_string

This receives an error but I struggle to see how I could provide a versioned package and it matches suggestions on the web. The Opam documentation is so abstract that I can’t figure it out. Also, does this still need a matching entry in the depends: [ ... "fit" {pinned} …] field?

1 Like

I don’t have answers to the questions you raise. However I believe this pin-depends here works.

So that would mean you need to define a version for fit e.g. fit.~dev. Possibly you may have to define a branch or commit after a # on the git repo.

The particular case I point to has no {pinned} filter in depends: (I think this is supposed to mean this dependency only exists whenever the package is pinned).


This should work:

pin-depends: [
  ["" "git+"]
1 Like

Thanks for all replies. To summarize, I believe:

  • the package is listed in depends
  • the package is connected to a repo in pin-depends
depends: [
  "dune" {>= "2.0"}
  "dream" {>= "1.0.0~alpha5"}
  "cmdliner" {>= "1.1.0"}

pin-depends: ["fit.~dev" "git+"]

That looks right to me.

I would add that you need to make sure the pinned package is actually installed. An example from my local work on ocaml-h2.

$ opam install . --deps-only --yes --with-test               
The following additional pinnings are required by h2-async.0.10.0:
  - at git+
  - at git+
Pin and install them? [Y/n] y
[] synchronised (no changes)
gluten-async is now pinned to git+ (version dev)
[] synchronised (no changes)
gluten is now pinned to git+ (version dev)
The following actions will be performed:
  ∗ install gluten-lwt      0.4.1
  ∗ install gluten-eio      0.4.1
  ∗ install gluten-mirage   0.4.1
  ∗ install gluten-lwt-unix 0.4.1
===== ∗ 4 =====

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
⬇ retrieved gluten-lwt.0.4.1  (cached)
⬇ retrieved gluten-mirage.0.4.1  (cached)
⬇ retrieved gluten-lwt-unix.0.4.1  (cached)
⬇ retrieved gluten-eio.0.4.1  (cached)
∗ installed gluten-eio.0.4.1
∗ installed gluten-lwt.0.4.1
∗ installed gluten-mirage.0.4.1
∗ installed gluten-lwt-unix.0.4.1

Querying the opam pin status shows that even though the pins exist they aren’t actually installed.

$ opam pin        (not in sync)  git  git+
                                      (installed:0.4.1)  (not in sync)  git  git+

A manual upgrade to the pinned dev version is required:

$ opam upgrade gluten gluten-async

<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><>  🐫 
[] synchronised (no changes)
[] synchronised (no changes)

The following actions will be performed:
  ⊘ remove  gluten-mirage   0.4.1         [uses gluten-lwt]
  ⊘ remove  gluten-lwt-unix 0.4.1         [uses gluten-lwt]
  ⊘ remove  gluten-eio      0.4.1         [conflicts with gluten]
  ⊘ remove  gluten-lwt      0.4.1         [conflicts with gluten]
  ↗ upgrade gluten          0.4.1 to dev*
  ↗ upgrade gluten-async    0.4.1 to dev*
===== ↗ 2   ⊘ 4 =====
Do you want to continue? [Y/n] y

There’s possibly a more direct set of commands but this is what I’ve been using.