OPAM-LOCK

Section: Opam Manual (1)
Updated:
Index Return to Main Contents
 

NAME

opam-lock - Create locked opam files to share build environments across hosts.  

SYNOPSIS

opam lock [OPTION]... [PACKAGES]...  

DESCRIPTION

Generates a lock file of a package: checks the current state of their installed dependencies, and outputs modified versions of the opam file with a .locked suffix, where all the (transitive) dependencies and pinnings have been bound strictly to the currently installed version.

By using these locked opam files, it is then possible to recover the precise build environment that was setup when they were generated.

If paths (filename or directory) are given, those opam files are locked. If package is given, installed one is locked, otherwise its latest version.

Fails if all mandatory dependencies are not installed in the switch.  

What is changed in the locked file?

- depends are fixed to their specific versions, with all filters removed (except for the exceptions below

- depopts that are installed in the current switch are turned into depends, with their version set. Others are set in the conflict field

- `{dev}`, `{with-test}, and `{with-doc}` filters are kept if all packages of a specific filters are installed in the switch. Versions are fixed and the same filter is on all dependencies that are added from them

- pin-depends are kept and new ones are added if in the dependencies some packages are pinned

- pins are resolved: if a package is locally pinned, opam tries to get its remote url and branch, and sets this as the target URL  

ARGUMENTS

PACKAGES
List of package names, with an optional version or constraint, e.g `pkg', `pkg.1.0' or `pkg>=0.5' ; or files or directory names containing package description, with explicit directory (e.g. `./foo.opam' or `.')
 

OPTIONS

--direct-only
Only lock direct dependencies, rather than the whole dependency tree.
--help[=FMT] (default=auto)
Show this help in format FMT. The value FMT must be one of `auto', `pager', `groff' or `plain'. With `auto', the format is `pager` or `plain' whenever the TERM env var is `dumb' or undefined.
--lock-suffix=SUFFIX (absent=locked)
Set locked files suffix to SUFFIX.
--version
Show version information.
 

COMMON OPTIONS

--best-effort
Don't fail if all requested packages can't be installed: try to install as many as possible. Note that not all external solvers may support this option (recent versions of aspcud or mccs should). This is equivalent to setting $OPAMBESTEFFORT environment variable.
--color=WHEN
Colorize the output. WHEN must be one of `always', `never' or `auto'.
--criteria=CRITERIA
Specify user preferences for dependency solving for this run. Overrides both $OPAMCRITERIA and $OPAMUPGRADECRITERIA. For details on the supported language, and the external solvers available, see http://opam.ocaml.org/doc/External_solvers.html. A general guide to using solver preferences can be found at http://www.dicosmo.org/Articles/usercriteria.pdf.
--cudf=FILENAME
Debug option: Save the CUDF requests sent to the solver to FILENAME-<n>.cudf.
--debug
Print debug message to stderr. This is equivalent to setting $OPAMDEBUG to "true".
--debug-level=LEVEL
Like --debug, but allows specifying the debug level (--debug sets it to 1). Equivalent to setting $OPAMDEBUG to a positive integer.
--git-version
Print the git version of opam, if set (i.e. you are using a development version), and exit.
--ignore-pin-depends
Ignore extra pins required by packages that get pinned, either manually through opam pin or through opam install DIR. This is equivalent to setting IGNOREPINDEPENDS=true.
--json=FILENAME
Save the results of the opam run in a computer-readable file. If the filename contains the character `%', it will be replaced by an index that doesn't overwrite an existing file. Similar to setting the $OPAMJSON variable.
--no-aspcud
Deprecated.
--no-auto-upgrade
When configuring or updating a repository that is written for an earlier opam version (1.2), opam internally converts it to the current format. This disables this behaviour. Note that repositories should define their format version in a 'repo' file at their root, or they will be assumed to be in the older format. It is, in any case, preferable to upgrade the repositories manually using opam admin upgrade [--mirror URL] when possible.
--no-self-upgrade
Opam will replace itself with a newer binary found at OPAMROOT/opam if present. This disables this behaviour.
-q, --quiet
Disables --verbose.
--root=ROOT
Use ROOT as the current root path. This is equivalent to setting $OPAMROOT to ROOT.
--safe, --readonly
Make sure nothing will be automatically updated or rewritten. Useful for calling from completion scripts, for example. Will fail whenever such an operation is needed ; also avoids waiting for locks, skips interactive questions and overrides the $OPAMDEBUG variable. This is equivalent to set environment variable $OPAMSAFE.
--solver=CMD
Specify the CUDF solver to use for resolving package installation problems. This is either a predefined solver (this version of opam supports builtin-mccs+lp(), builtin-mccs+glpk, builtin-dummy-z3-solver, builtin-dummy-0install-solver, aspcud, mccs, aspcud-old, packup), or a custom command that should contain the variables %{input}%, %{output}%, %{criteria}%, and optionally %{timeout}%. This is equivalent to setting $OPAMEXTERNALSOLVER.
--strict
Fail whenever an error is found in a package definition or a configuration file. The default is to continue silently if possible.
--switch=SWITCH
Use SWITCH as the current compiler switch. This is equivalent to setting $OPAMSWITCH to SWITCH.
--use-internal-solver
Disable any external solver, and use the built-in one (this requires that opam has been compiled with a built-in solver). This is equivalent to setting $OPAMNOASPCUD or $OPAMUSEINTERNALSOLVER.
-v, --verbose
Be more verbose. One -v shows all package commands, repeat to also display commands called internally (e.g. tar, curl, patch etc.) Repeating n times is equivalent to setting $OPAMVERBOSE to "n".
-w, --working-dir
Whenever updating packages that are bound to a local, version-controlled directory, update to the current working state of their source instead of the last committed state, or the ref they are pointing to. As source directory is copied as it is, it it isn't clean it may result on a opam build failure.This only affects packages explicitly listed on the command-line.It can also be set with $OPAMWORKINGDIR.
-y, --yes
Answer yes to all yes/no questions without prompting. This is equivalent to setting $OPAMYES to "true".

 

Index

NAME
SYNOPSIS
DESCRIPTION
What is changed in the locked file?
ARGUMENTS
OPTIONS
COMMON OPTIONS

This document was created by man2html, using the manual pages.
Time: 01:01:10 GMT, August 12, 2020