英文:
How to specify requirements for versions of dependencies for ocaml dune projects?
问题
-
我如何指定
foobar
库应该有特定的确切版本? -
如果我们知道
foobar
库使用语义版本控制,我如何指定需要主版本号为 3 的任何版本?
英文:
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
答案1
得分: 2
项目的软件包依赖关系在 dune-project
文件中指定,详见 https://dune.readthedocs.io/en/stable/dune-files.html#package
通过 dune init proj ...
生成默认的 dune-project
文件。
要添加带有版本约束的依赖项,请在 depends
字段中添加一行,如下所示:
(depends
(foobar (>= 3))
请注意,这是为了补充指定可执行组件依赖的库,这是在 bin/dune
文件中完成的。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论