简体   繁体   English

如何使用 ocamlfind 或 opam 获取已安装的 package 的版本?

[英]How to get the version of a installed package using ocamlfind or opam?

In my configure script, I need to check the installed version of a package <package> using ocamlfind or opam .在我的配置脚本中,我需要使用ocamlfindopam检查 package <package>的安装版本。 How do I get this information?我如何获得这些信息?

Using ocamlfind: ocamlfind query -format %v <package>使用 ocamlfind: ocamlfind query -format %v <package>

This information is not directly available when running ocamlfind query --help , but it is available with ocamlfind query -help-format , which displays it among the other format options:此信息在运行ocamlfind query --help时不直接可用,但可通过ocamlfind query -help-format获得,它会在其他格式选项中显示它:

 Formats for -format strings: ... %v version...

Using opam: opam info -f installed-version <package>使用 opam: opam info -f installed-version <package>

It returns -- when the package is not installed.它返回--当 package 未安装时。

This comes from opam info --help :这来自opam info --help

 -f FIELDS, --field=FIELDS Only display the values of these fields. Fields can be selected among name, version, package, synopsis, synopsis-or-target, description, <field>:, installed-version, pin, source-hash, opam-file, all-installed-versions, available-versions, all-versions, repository, installed-files, vc-ref, depexts. Multiple fields can be separated with commas, in which case field titles will be printed; the raw value of any opam-file field can be queried by suffixing a colon character (:), eg --field=depopts:.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM