1OPAM-LOCK(1) Opam Manual OPAM-LOCK(1)
2
3
4
6 opam-lock - Create locked opam files to share build environments across
7 hosts.
8
10 opam lock [OPTION]… [PACKAGES]…
11
13 Generates a lock file of a package: checks the current state of their
14 installed dependencies, and outputs modified versions of the opam file
15 with a .locked suffix, where all the (transitive) dependencies and
16 pinnings have been bound strictly to the currently installed version.
17
18 By using these locked opam files, it is then possible to recover the
19 precise build environment that was setup when they were generated.
20
21 If paths (filename or directory) are given, those opam files are
22 locked. If package is given, installed one is locked, otherwise its
23 latest version. If a locally pinned package is given, its current local
24 opam file is locked, even if not versioned or uncommitted changes
25
26 Fails if all mandatory dependencies are not installed in the switch.
27
29 - depends are fixed to their specific versions, with all filters
30 removed (except for the exceptions below
31
32 - depopts that are installed in the current switch are turned into
33 depends, with their version set. Others are set in the conflict field
34
35 - `{dev}`, `{with-test}, and `{with-doc}` filters are kept if all
36 packages of a specific filters are installed in the switch. Versions
37 are fixed and the same filter is on all dependencies that are added
38 from them
39
40 - pin-depends are kept and new ones are added if in the dependencies
41 some packages are pinned
42
43 - pins are resolved: if a package is locally pinned, opam tries to get
44 its remote url and branch, and sets this as the target URL
45
47 PACKAGES
48 List of package names, with an optional version or constraint, e.g
49 `pkg', `pkg.1.0' or `pkg>=0.5' ; or files or directory names
50 containing package description, with explicit directory (e.g.
51 `./foo.opam' or `.')
52
54 -d, --direct-only
55 Only lock direct dependencies, rather than the whole dependency
56 tree.
57
58 --lock-suffix=SUFFIX (absent=locked)
59 Set locked files suffix to SUFFIX.
60
61 --no
62 Answer no to all opam yes/no questions without prompting. See also
63 --confirm-level. This is equivalent to setting $OPAMNO to "true".
64
65 -y, --yes
66 Answer yes to all opam yes/no questions without prompting. See also
67 --confirm-level. This is equivalent to setting $OPAMYES to "true".
68
70 These options are common to all commands.
71
72 --best-effort
73 Don't fail if all requested packages can't be installed: try to
74 install as many as possible. Note that not all external solvers may
75 support this option (recent versions of aspcud or mccs should).
76 This is equivalent to setting $OPAMBESTEFFORT environment variable.
77
78 --cli=MAJOR.MINOR (absent=2.1)
79 Use the command-line interface syntax and semantics of MAJOR.MINOR.
80 Intended for any persistent use of opam (scripts, blog posts,
81 etc.), any version of opam in the same MAJOR series will behave as
82 for the specified MINOR release. The flag was not available in opam
83 2.0, so to select the 2.0 CLI, set the OPAMCLI environment variable
84 to 2.0 instead of using this parameter.
85
86 --color=WHEN
87 Colorize the output. WHEN must be one of always, never or auto.
88
89 --confirm-level=LEVEL
90 Confirmation level, LEVEL must be one of ask, no, yes or
91 unsafe-yes. Can be specified more than once. If --yes or --no are
92 also given, the value of the last --confirm-level is taken into
93 account. This is equivalent to setting $OPAMCONFIRMLEVEL`.
94
95 --criteria=CRITERIA
96 Specify user preferences for dependency solving for this run.
97 Overrides both $OPAMCRITERIA and $OPAMUPGRADECRITERIA. For details
98 on the supported language, and the external solvers available, see
99 http://opam.ocaml.org/doc/External_solvers.html. A general guide to
100 using solver preferences can be found at
101 http://www.dicosmo.org/Articles/usercriteria.pdf.
102
103 --cudf=FILENAME
104 Debug option: Save the CUDF requests sent to the solver to
105 FILENAME-<n>.cudf.
106
107 --debug
108 Print debug message to stderr. This is equivalent to setting
109 $OPAMDEBUG to "true".
110
111 --debug-level=LEVEL
112 Like --debug, but allows specifying the debug level (--debug sets
113 it to 1). Equivalent to setting $OPAMDEBUG to a positive integer.
114
115 --git-version
116 Print the git version of opam, if set (i.e. you are using a
117 development version), and exit.
118
119 --help[=FMT] (default=auto)
120 Show this help in format FMT. The value FMT must be one of auto,
121 pager, groff or plain. With auto, the format is pager or plain
122 whenever the TERM env var is dumb or undefined.
123
124 --ignore-pin-depends
125 Ignore extra pins required by packages that get pinned, either
126 manually through opam pin or through opam install DIR. This is
127 equivalent to setting IGNOREPINDEPENDS=true.
128
129 --json=FILENAME
130 Save the results of the opam run in a computer-readable file. If
131 the filename contains the character `%', it will be replaced by an
132 index that doesn't overwrite an existing file. Similar to setting
133 the $OPAMJSON variable.
134
135 --no-aspcud
136 Removed in 2.1.
137
138 --no-auto-upgrade
139 When configuring or updating a repository that is written for an
140 earlier opam version (1.2), opam internally converts it to the
141 current format. This disables this behaviour. Note that
142 repositories should define their format version in a 'repo' file at
143 their root, or they will be assumed to be in the older format. It
144 is, in any case, preferable to upgrade the repositories manually
145 using opam admin upgrade [--mirror URL] when possible.
146
147 --no-self-upgrade
148 Opam will replace itself with a newer binary found at OPAMROOT/opam
149 if present. This disables this behaviour.
150
151 -q, --quiet
152 Disables --verbose.
153
154 --root=ROOT
155 Use ROOT as the current root path. This is equivalent to setting
156 $OPAMROOT to ROOT.
157
158 --safe, --readonly
159 Make sure nothing will be automatically updated or rewritten.
160 Useful for calling from completion scripts, for example. Will fail
161 whenever such an operation is needed ; also avoids waiting for
162 locks, skips interactive questions and overrides the $OPAMDEBUG
163 variable. This is equivalent to set environment variable $OPAMSAFE.
164
165 --solver=CMD
166 Specify the CUDF solver to use for resolving package installation
167 problems. This is either a predefined solver (this version of opam
168 supports builtin-mccs+lp(), builtin-mccs+glpk,
169 builtin-dummy-z3-solver, builtin-dummy-0install-solver, aspcud,
170 mccs, aspcud-old, packup), or a custom command that should contain
171 the variables %{input}%, %{output}%, %{criteria}%, and optionally
172 %{timeout}%. This is equivalent to setting $OPAMEXTERNALSOLVER.
173
174 --strict
175 Fail whenever an error is found in a package definition or a
176 configuration file. The default is to continue silently if
177 possible.
178
179 --switch=SWITCH
180 Use SWITCH as the current compiler switch. This is equivalent to
181 setting $OPAMSWITCH to SWITCH.
182
183 --use-internal-solver
184 Disable any external solver, and use the built-in one (this
185 requires that opam has been compiled with a built-in solver). This
186 is equivalent to setting $OPAMNOASPCUD or $OPAMUSEINTERNALSOLVER.
187
188 -v, --verbose
189 Be more verbose. One -v shows all package commands, repeat to also
190 display commands called internally (e.g. tar, curl, patch etc.)
191 Repeating n times is equivalent to setting $OPAMVERBOSE to "n".
192
193 --version
194 Show version information.
195
196 -w, --working-dir
197 Whenever updating packages that are bound to a local,
198 version-controlled directory, update to the current working state
199 of their source instead of the last committed state, or the ref
200 they are pointing to. As source directory is copied as it is, if it
201 isn't clean it may result on a opam build failure.This only affects
202 packages explicitly listed on the command-line.It can also be set
203 with $OPAMWORKINGDIR.
204
206 Opam makes use of the environment variables listed here. Boolean
207 variables should be set to "0", "no", "false" or the empty string to
208 disable, "1", "yes" or "true" to enable.
209
210 OPAMALLPARENS surround all filters with parenthesis.
211
212 OPAMASSUMEDEPEXTS see option `--assume-depexts'.
213
214 OPAMAUTOREMOVE see remove option `--auto-remove'.
215
216 OPAMBESTEFFORT see option `--best-effort'.
217
218 OPAMBESTEFFORTPREFIXCRITERIA sets the string that must be prepended to
219 the criteria when the `--best-effort' option is set, and is expected to
220 maximise the `opam-query' property in the solution.
221
222 OPAMBUILDDOC Removed in 2.1.
223
224 OPAMBUILDTEST Removed in 2.1.
225
226 OPAMCLI see option `--cli'.
227
228 OPAMCOLOR when set to always or never, sets a default value for the
229 `--color' option.
230
231 OPAMCONFIRMLEVEL see option `--confirm-level`. OPAMCONFIRMLEVEL has
232 priority over OPAMYES and OPAMNO.
233
234 OPAMCRITERIA specifies user preferences for dependency solving. The
235 default value depends on the solver version, use `config report' to
236 know the current setting. See also option --criteria.
237
238 OPAMCUDFFILE save the cudf graph to file-actions-explicit.dot.
239
240 OPAMCUDFTRIM controls the filtering of unrelated packages during CUDF
241 preprocessing.
242
243 OPAMCURL can be used to select a given 'curl' program. See OPAMFETCH
244 for more options.
245
246 OPAMDEBUG see options `--debug' and `--debug-level'.
247
248 OPAMDEBUGSECTIONS if set, limits debug messages to the space-separated
249 list of sections. Sections can optionally have a specific debug level
250 (for example, CLIENT:2 or CLIENT CUDF:2), but otherwise use
251 `--debug-level'.
252
253 OPAMDIGDEPTH defines how aggressive the lookup for conflicts during
254 CUDF preprocessing is.
255
256 OPAMDOWNLOADJOBS sets the maximum number of simultaneous downloads.
257
258 OPAMDROPWORKINGDIR overrides packages previously updated with
259 --working-dir on update. Without this variable set, opam would keep
260 them unchanged unless explicitly named on the command-line.
261
262 OPAMDRYRUN see option `--dry-run'.
263
264 OPAMEDITOR sets the editor to use for opam file editing, overrides
265 $EDITOR and $VISUAL.
266
267 OPAMERRLOGLEN sets the number of log lines printed when a sub-process
268 fails. 0 to print all.
269
270 OPAMEXTERNALSOLVER see option `--solver'.
271
272 OPAMFAKE see option `--fake'.
273
274 OPAMFETCH specifies how to download files: either `wget', `curl' or a
275 custom command where variables %{url}%, %{out}%, %{retry}%,
276 %{compress}% and %{checksum}% will be replaced. Overrides the
277 'download-command' value from the main config file.
278
279 OPAMFIXUPCRITERIA same as OPAMUPGRADECRITERIA, but specific to fixup.
280
281 OPAMIGNORECONSTRAINTS see install option `--ignore-constraints-on'.
282
283 OPAMIGNOREPINDEPENDS see option `--ignore-pin-depends'.
284
285 OPAMINPLACEBUILD see option `--inplace-build'.
286
287 OPAMJOBS sets the maximum number of parallel workers to run.
288
289 OPAMJSON log json output to the given file (use character `%' to index
290 the files).
291
292 OPAMKEEPBUILDDIR see install option `--keep-build-dir'.
293
294 OPAMKEEPLOGS tells opam to not remove some temporary command logs and
295 some backups. This skips some finalisers and may also help to get more
296 reliable backtraces.
297
298 OPAMLOCKED combination of `--locked' and `--lock-suffix' options.
299
300 OPAMLOGS logdir sets log directory, default is a temporary directory in
301 /tmp
302
303 OPAMMAKECMD set the system make command to use.
304
305 OPAMMERGEOUT merge process outputs, stderr on stdout.
306
307 OPAMNO answer no to any question asked, see options `--no` and
308 `--confirm-level`. OPAMNO is ignored if either OPAMCONFIRMLEVEL or
309 OPAMYES is set.
310
311 OPAMNOAGGREGATE with `opam admin check', don't aggregate packages.
312
313 OPAMNOASPCUD Deprecated.
314
315 OPAMNOAUTOUPGRADE disables automatic internal upgrade of repositories
316 in an earlier format to the current one, on 'update' or 'init'.
317
318 OPAMNOCHECKSUMS enables option --no-checksums when available.
319
320 OPAMNODEPEXTS disables system dependencies handling, see option
321 `--no-depexts'.
322
323 OPAMNOENVNOTICE Internal.
324
325 OPAMNOSELFUPGRADE see option `--no-self-upgrade'
326
327 OPAMPINKINDAUTO sets whether version control systems should be detected
328 when pinning to a local path. Enabled by default since 1.3.0.
329
330 OPAMPRECISETRACKING fine grain tracking of directories.
331
332 OPAMPREPRO set this to false to disable CUDF preprocessing. Less
333 efficient, but might help debugging solver issue.
334
335 OPAMREQUIRECHECKSUMS Enables option `--require-checksums' when
336 available (e.g. for `opam install').
337
338 OPAMRETRIES sets the number of tries before failing downloads.
339
340 OPAMREUSEBUILDDIR see option `--reuse-build-dir'.
341
342 OPAMROOT see option `--root'. This is automatically set by `opam env
343 --root=DIR --set-root'.
344
345 OPAMROOTISOK don't complain when running as root.
346
347 OPAMSAFE see option `--safe'.
348
349 OPAMSHOW see option `--show'.
350
351 OPAMSKIPUPDATE see option `--skip-updates'.
352
353 OPAMSKIPVERSIONCHECKS bypasses some version checks. Unsafe, for
354 compatibility testing only.
355
356 OPAMSOLVERALLOWSUBOPTIMAL (default `true') allows some solvers to still
357 return a solution when they reach timeout; while the solution remains
358 assured to be consistent, there is no guarantee in this case that it
359 fits the expected optimisation criteria. If `true', opam willcontinue
360 with a warning, if `false' a timeout is an error. Currently only the
361 builtin-z3 backend handles this degraded case.
362
363 OPAMSOLVERTIMEOUT change the time allowance of the solver. Default is
364 60.0, set to 0 for unlimited. Note that all solvers may not support
365 this option.
366
367 OPAMSTATS display stats at the end of command.
368
369 OPAMSTATUSLINE display a dynamic status line showing what's currently
370 going on on the terminal. (one of one of always, never or auto)
371
372 OPAMSTRICT fail on inconsistencies (file reading, switch import, etc.).
373
374 OPAMSWITCH see option `--switch'. Automatically set by `opam env
375 --switch=SWITCH --set-switch'.
376
377 OPAMUNLOCKBASE see install option `--unlock-base'.
378
379 OPAMUPGRADECRITERIA specifies user preferences for dependency solving
380 when performing an upgrade. Overrides OPAMCRITERIA in upgrades if both
381 are set. See also option --criteria.
382
383 OPAMUSEINTERNALSOLVER see option `--use-internal-solver'.
384
385 OPAMUSEOPENSSL force openssl use for hash computing.
386
387 OPAMUTF8 use UTF8 characters in output (one of one of always, never or
388 auto). By default `auto', which is determined from the locale).
389
390 OPAMUTF8MSGS use extended UTF8 characters (camels) in opam messages.
391 Implies OPAMUTF8. This is set by default on OSX only.
392
393 OPAMVALIDATIONHOOK if set, uses the `%{hook%}' command to validate an
394 opam repository update.
395
396 OPAMVERBOSE see option `--verbose'.
397
398 OPAMVERSIONLAGPOWER do not use.
399
400 OPAMWITHDOC see install option `--with-doc'.
401
402 OPAMWITHTEST see install option `--with-test.
403
404 OPAMWORKINGDIR see option `--working-dir'.
405
406 OPAMYES see options `--yes' and `--confirm-level`. OPAMYES has has
407 priority over OPAMNO and is ignored if OPAMCONFIRMLEVEL is set.
408
409 OPAMVAR_var overrides the contents of the variable var when
410 substituting `%{var}%` strings in `opam` files.
411
412 OPAMVAR_package_var overrides the contents of the variable package:var
413 when substituting `%{package:var}%` strings in `opam` files.
414
416 All scripts and programmatic invocations of opam should use `--cli' in
417 order to ensure that they work seamlessly with future versions of the
418 opam client. Additionally, blog posts or other documentation can
419 benefit, as it prevents information from becoming stale.
420
421 Although opam only supports roots (~/.opam/) for the current version,
422 it does provide backwards compatibility for its command-line interface.
423
424 Since CLI version support was only added in opam 2.1, use OPAMCLI to
425 select 2.0 support (as opam 2.0 will just ignore it), and `--cli=2.1'
426 for 2.1 (or later) versions, since an environment variable controlling
427 the parsing of syntax is brittle. To this end, opam displays a warning
428 if OPAMCLI specifies a valid version other than 2.0, and also if
429 `--cli=2.0' is specified.
430
431 The command-line version is selected by using the `--cli' option or the
432 OPAMCLI environment variable. `--cli' may be specified morethan once,
433 where the last instance takes precedence. OPAMCLI is only inspected if
434 `--cli' is not given.
435
437 As an exception to the following, the `exec' command returns 127 if the
438 command was not found or couldn't be executed, and the command's exit
439 value otherwise.
440
441 0 Success, or true for boolean queries.
442
443 1 False. Returned when a boolean return value is expected, e.g. when
444 running with --check, or for queries like opam lint.
445
446 2 Bad command-line arguments, or command-line arguments pointing to
447 an invalid context (e.g. file not following the expected format).
448
449 5 Not found. You requested something (package, version, repository,
450 etc.) that couldn't be found.
451
452 10 Aborted. The operation required confirmation, which wasn't given.
453
454 15 Could not acquire the locks required for the operation.
455
456 20 There is no solution to the user request. This can be caused by
457 asking to install two incompatible packages, for example.
458
459 30 Error in package definition, or other metadata files. Using
460 --strict raises this error more often.
461
462 31 Package script error. Some package operations were unsuccessful.
463 This may be an error in the packages or an incompatibility with
464 your system. This can be a partial error.
465
466 40 Sync error. Could not fetch some remotes from the network. This can
467 be a partial error.
468
469 50 Configuration error. Opam or system configuration doesn't allow
470 operation, and needs fixing.
471
472 60 Solver failure. The solver failed to return a sound answer. It can
473 be due to a broken external solver, or an error in solver
474 configuration.
475
476 99 Internal error. Something went wrong, likely due to a bug in opam
477 itself.
478
479 130 User interrupt. SIGINT was received, generally due to the user
480 pressing Ctrl-C.
481
483 See https://opam.ocaml.org/doc.
484
486 Vincent Bernardoff <vb@luminar.eu.org>
487 Raja Boujbel <raja.boujbel@ocamlpro.com>
488 Roberto Di Cosmo <roberto@dicosmo.org>
489 Thomas Gazagnaire <thomas@gazagnaire.org>
490 Louis Gesbert <louis.gesbert@ocamlpro.com>
491 Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr>
492 Anil Madhavapeddy <anil@recoil.org>
493 Guillem Rieu <guillem.rieu@ocamlpro.com>
494 Ralf Treinen <ralf.treinen@pps.jussieu.fr>
495 Frederic Tuong <tuong@users.gforge.inria.fr>
496
498 Check bug reports at https://github.com/ocaml/opam/issues.
499
500
501
502Opam 2.1.3 OPAM-LOCK(1)