4

Say I run dune init proj hello_world, then modify the bin/dune and bin/main.ml files so that a new dependency foobar is in use.

The bin/dune file now:

(executable
 (public_name hello_world)
 (name main)
 (libraries hello_world foobar))

1. How can I specify that the foobar library should have a certain exact version?

2. If we know that the foobar library uses semantic versioning, how could I specify that any version with the major version as 3 is required?

ocaml version 4.14.0
dune version 3.6.1

Costava
  • 175
  • 9

1 Answers1

2

Package dependencies for a project are specified in the dune-project file, see https://dune.readthedocs.io/en/stable/dune-files.html#package

A default dune-project file is generated by dune init proj ....

To add a dependency with a version constraint, add a line in the depends field like

(depends 
  (foobar (>= 3))

Note that this is needed in addition to specifying which libraries the executable component depends on, which is what you have on the bin/dune file.

Shon
  • 3,989
  • 1
  • 22
  • 35