1OPAM-INSTALL(1) Opam Manual OPAM-INSTALL(1)
2
3
4
6 opam-install - Install a list of packages.
7
9 opam install [OPTION]… [PACKAGES]…
10
12 This command installs one or more packages inside the currently
13 selected switch (see opam switch). Once installed, you can remove
14 packages with opam remove, upgrade them with opam upgrade, and list
15 them with opam list. See opam pin as well to manage package versions,
16 reroute existing packages or add packages that are not defined in the
17 repositories.
18
19 All required dependencies of the selected packages will be installed
20 first. Any already installed packages having dependencies, or optional
21 dependencies to the changed packages will be recompiled. The proposed
22 solution may also imply removing incompatible or conflicting packages.
23
24 If paths are provided as argument instead of packages, they are assumed
25 to point to either project source directories containing one or more
26 package definitions (opam files), or directly to opam files. Then the
27 corresponding packages will be pinned to their local directory and
28 installed (unless --deps-only was specified).
29
31 PACKAGES
32 List of package names, with an optional version or constraint, e.g
33 `pkg', `pkg.1.0' or `pkg>=0.5' ; or files or directory names
34 containing package description, with explicit directory (e.g.
35 `./foo.opam' or `.')
36
38 --assume-built
39 For use on locally-pinned packages: assume they have already been
40 correctly built, and only run their installation instructions,
41 directly from their source directory. This skips the build
42 instructions and can be useful to install packages that are being
43 worked on. Implies --inplace-build. No locally-pinned packages will
44 be skipped.
45
46 --check
47 Exit with 0 if all the dependencies of PACKAGES are already
48 installed. If not, output the names of the missing dependencies to
49 stdout, and exits with 1.
50
51 --depext-only
52 Resolves the package installation normally, but only installs the
53 required system dependencies, without affecting the opam switch
54 state or installing opam packages.
55
56 --deps-only
57 Install all its dependencies, but don't actually install the
58 package.
59
60 --destdir=DIR
61 Copy the files installed by the given package within the current
62 opam switch below the prefix DIR, respecting their hierarchy, after
63 installation. Caution, calling this can overwrite, but never remove
64 files, even if they were installed by a previous use of --destdir,
65 e.g. on a previous version of the same package. See opam remove
66 --destdir to revert.
67
68 --download-only
69 Fetch the sources of the packages, but don't build or install
70 anything.
71
72 --ignore-conflicts
73 Used with --deps-only, ignores conflicts of given package
74
75 -j JOBS, --jobs=JOBS
76 Set the maximal number of concurrent jobs to use. The default value
77 is calculated from the number of cores. You can also set it using
78 the $OPAMJOBS environment variable.
79
80 --no
81 Answer no to all opam yes/no questions without prompting. See also
82 --confirm-level. This is equivalent to setting $OPAMNO to "true".
83
84 --restore
85 Attempt to restore packages that were marked for installation but
86 have been removed due to errors
87
88 --set-root
89 Mark given packages as installed roots. This is the default for
90 newly manually-installed packages.
91
92 --unset-root
93 Mark given packages as "installed automatically".
94
95 -y, --yes
96 Answer yes to all opam yes/no questions without prompting. See also
97 --confirm-level. This is equivalent to setting $OPAMYES to "true".
98
100 --assume-depexts
101 Skip the installation step for any missing system packages, and
102 attempt to proceed with compilation of the opam packages anyway. If
103 the installation is successful, opam won't prompt again about these
104 system packages. Only meaningful if external dependency handling is
105 enabled.
106
107 -b, --keep-build-dir
108 Keep the build directories after compiling packages. This is
109 equivalent to setting $OPAMKEEPBUILDDIR to "true".
110
111 --build-doc
112 Removed in 2.1, use --with-doc instead.
113
114 --build-test
115 Removed in 2.1, use --with-test instead.
116
117 -d, --with-doc
118 Build the package documentation. This only affects packages listed
119 on the command-line. This is equivalent to setting $OPAMWITHDOC (or
120 the deprecated $OPAMBUILDDOC) to "true".
121
122 --dry-run
123 Simulate the command, but don't actually perform any changes. This
124 also can be set with environment variable $OPAMDEBUG.
125
126 --fake
127 This option registers the actions into the opam database, without
128 actually performing them. WARNING: This option is dangerous and
129 likely to break your opam environment. You probably want --dry-run.
130 You've been warned.
131
132 --ignore-constraints-on[=PACKAGES] (default=)
133 Forces opam to ignore version constraints on all dependencies to
134 the listed packages. This can be used to test compatibility, but
135 expect builds to break when using this. Note that version
136 constraints on optional dependencies and conflicts are unaffected.
137 This is equivalent to setting $OPAMIGNORECONSTRAINTS.
138
139 --inplace-build
140 When compiling a package which has its source bound to a local
141 directory, process the build and install actions directly in that
142 directory, rather than in a clean copy handled by opam. This only
143 affects packages that are explicitly listed on the command-line.
144 This is equivalent to setting $OPAMINPLACEBUILD to "true".
145
146 --lock-suffix=SUFFIX (absent=locked)
147 Set locked files suffix to SUFFIX.
148
149 --locked
150 In commands that use opam files found from pinned sources, if a
151 variant of the file with an added .locked extension is found (e.g.
152 foo.opam.locked besides foo.opam), that will be used instead. This
153 is typically useful to offer a more specific set of dependencies
154 and reproduce similar build contexts, hence the name. The
155 lockoption can be used to generate such files, based on the
156 versions of the dependencies currently installed on the host. This
157 is equivalent to setting the $OPAMLOCKED environment variable. Note
158 that this option doesn't generally affect already pinned packages.
159
160 -m MAKE, --make=MAKE
161 Removed in 2.1, use opam config set[-global] make MAKE instead.
162
163 --no-checksums
164 Do not verify the checksum of downloaded archives.This is
165 equivalent to setting $OPAMNOCHECKSUMS to "true".
166
167 --no-depexts
168 Temporarily disables handling of external dependencies. This can be
169 used if a package is not available on your system package manager,
170 but you installed the required dependency by hand. Implies
171 --assume-depexts, and stores the exceptions upon success as well.
172
173 --require-checksums
174 Reject the installation of packages that don't provide a checksum
175 for the upstream archives. This is equivalent to setting
176 $OPAMREQUIRECHECKSUMS to "true".
177
178 --reuse-build-dir
179 Reuse existing build directories (kept by using --keep-build-dir),
180 instead of compiling from a fresh clone of the source. This can be
181 faster, but also lead to failures if the build systems of the
182 packages don't handle upgrades of dependencies well. This is
183 equivalent to setting $OPAMREUSEBUILDDIR to "true".
184
185 --show-actions
186 Call the solver and display the actions. Don't perform any changes.
187 This is equivalent to setting $OPAMSHOW.
188
189 --skip-updates
190 When running an install, upgrade or reinstall on source-pinned
191 packages, they are normally updated from their origin first. This
192 flag disables that behaviour and will keep them to their version in
193 cache. This is equivalent to setting $OPAMSKIPUPDATE.
194
195 -t, --with-test
196 Build and run the package unit-tests. This only affects packages
197 listed on the command-line. This is equivalent to setting
198 $OPAMWITHTEST (or the deprecated $OPAMBUILDTEST) to "true".
199
200 --unlock-base
201 Removed in 2.1, use --update-invariant instead.
202
203 --update-invariant
204 Allow changes to the packages set as switch base (typically, the
205 main compiler). Use with caution. This is equivalent to setting the
206 $OPAMUNLOCKBASE environment variable
207
209 These options are common to all commands.
210
211 --best-effort
212 Don't fail if all requested packages can't be installed: try to
213 install as many as possible. Note that not all external solvers may
214 support this option (recent versions of aspcud or mccs should).
215 This is equivalent to setting $OPAMBESTEFFORT environment variable.
216
217 --cli=MAJOR.MINOR (absent=2.1)
218 Use the command-line interface syntax and semantics of MAJOR.MINOR.
219 Intended for any persistent use of opam (scripts, blog posts,
220 etc.), any version of opam in the same MAJOR series will behave as
221 for the specified MINOR release. The flag was not available in opam
222 2.0, so to select the 2.0 CLI, set the OPAMCLI environment variable
223 to 2.0 instead of using this parameter.
224
225 --color=WHEN
226 Colorize the output. WHEN must be one of always, never or auto.
227
228 --confirm-level=LEVEL
229 Confirmation level, LEVEL must be one of ask, no, yes or
230 unsafe-yes. Can be specified more than once. If --yes or --no are
231 also given, the value of the last --confirm-level is taken into
232 account. This is equivalent to setting $OPAMCONFIRMLEVEL`.
233
234 --criteria=CRITERIA
235 Specify user preferences for dependency solving for this run.
236 Overrides both $OPAMCRITERIA and $OPAMUPGRADECRITERIA. For details
237 on the supported language, and the external solvers available, see
238 http://opam.ocaml.org/doc/External_solvers.html. A general guide to
239 using solver preferences can be found at
240 http://www.dicosmo.org/Articles/usercriteria.pdf.
241
242 --cudf=FILENAME
243 Debug option: Save the CUDF requests sent to the solver to
244 FILENAME-<n>.cudf.
245
246 --debug
247 Print debug message to stderr. This is equivalent to setting
248 $OPAMDEBUG to "true".
249
250 --debug-level=LEVEL
251 Like --debug, but allows specifying the debug level (--debug sets
252 it to 1). Equivalent to setting $OPAMDEBUG to a positive integer.
253
254 --git-version
255 Print the git version of opam, if set (i.e. you are using a
256 development version), and exit.
257
258 --help[=FMT] (default=auto)
259 Show this help in format FMT. The value FMT must be one of auto,
260 pager, groff or plain. With auto, the format is pager or plain
261 whenever the TERM env var is dumb or undefined.
262
263 --ignore-pin-depends
264 Ignore extra pins required by packages that get pinned, either
265 manually through opam pin or through opam install DIR. This is
266 equivalent to setting IGNOREPINDEPENDS=true.
267
268 --json=FILENAME
269 Save the results of the opam run in a computer-readable file. If
270 the filename contains the character `%', it will be replaced by an
271 index that doesn't overwrite an existing file. Similar to setting
272 the $OPAMJSON variable.
273
274 --no-aspcud
275 Removed in 2.1.
276
277 --no-auto-upgrade
278 When configuring or updating a repository that is written for an
279 earlier opam version (1.2), opam internally converts it to the
280 current format. This disables this behaviour. Note that
281 repositories should define their format version in a 'repo' file at
282 their root, or they will be assumed to be in the older format. It
283 is, in any case, preferable to upgrade the repositories manually
284 using opam admin upgrade [--mirror URL] when possible.
285
286 --no-self-upgrade
287 Opam will replace itself with a newer binary found at OPAMROOT/opam
288 if present. This disables this behaviour.
289
290 -q, --quiet
291 Disables --verbose.
292
293 --root=ROOT
294 Use ROOT as the current root path. This is equivalent to setting
295 $OPAMROOT to ROOT.
296
297 --safe, --readonly
298 Make sure nothing will be automatically updated or rewritten.
299 Useful for calling from completion scripts, for example. Will fail
300 whenever such an operation is needed ; also avoids waiting for
301 locks, skips interactive questions and overrides the $OPAMDEBUG
302 variable. This is equivalent to set environment variable $OPAMSAFE.
303
304 --solver=CMD
305 Specify the CUDF solver to use for resolving package installation
306 problems. This is either a predefined solver (this version of opam
307 supports builtin-mccs+lp(), builtin-mccs+glpk,
308 builtin-dummy-z3-solver, builtin-dummy-0install-solver, aspcud,
309 mccs, aspcud-old, packup), or a custom command that should contain
310 the variables %{input}%, %{output}%, %{criteria}%, and optionally
311 %{timeout}%. This is equivalent to setting $OPAMEXTERNALSOLVER.
312
313 --strict
314 Fail whenever an error is found in a package definition or a
315 configuration file. The default is to continue silently if
316 possible.
317
318 --switch=SWITCH
319 Use SWITCH as the current compiler switch. This is equivalent to
320 setting $OPAMSWITCH to SWITCH.
321
322 --use-internal-solver
323 Disable any external solver, and use the built-in one (this
324 requires that opam has been compiled with a built-in solver). This
325 is equivalent to setting $OPAMNOASPCUD or $OPAMUSEINTERNALSOLVER.
326
327 -v, --verbose
328 Be more verbose. One -v shows all package commands, repeat to also
329 display commands called internally (e.g. tar, curl, patch etc.)
330 Repeating n times is equivalent to setting $OPAMVERBOSE to "n".
331
332 --version
333 Show version information.
334
335 -w, --working-dir
336 Whenever updating packages that are bound to a local,
337 version-controlled directory, update to the current working state
338 of their source instead of the last committed state, or the ref
339 they are pointing to. As source directory is copied as it is, if it
340 isn't clean it may result on a opam build failure.This only affects
341 packages explicitly listed on the command-line.It can also be set
342 with $OPAMWORKINGDIR.
343
345 Opam makes use of the environment variables listed here. Boolean
346 variables should be set to "0", "no", "false" or the empty string to
347 disable, "1", "yes" or "true" to enable.
348
349 OPAMALLPARENS surround all filters with parenthesis.
350
351 OPAMASSUMEDEPEXTS see option `--assume-depexts'.
352
353 OPAMAUTOREMOVE see remove option `--auto-remove'.
354
355 OPAMBESTEFFORT see option `--best-effort'.
356
357 OPAMBESTEFFORTPREFIXCRITERIA sets the string that must be prepended to
358 the criteria when the `--best-effort' option is set, and is expected to
359 maximise the `opam-query' property in the solution.
360
361 OPAMBUILDDOC Removed in 2.1.
362
363 OPAMBUILDTEST Removed in 2.1.
364
365 OPAMCLI see option `--cli'.
366
367 OPAMCOLOR when set to always or never, sets a default value for the
368 `--color' option.
369
370 OPAMCONFIRMLEVEL see option `--confirm-level`. OPAMCONFIRMLEVEL has
371 priority over OPAMYES and OPAMNO.
372
373 OPAMCRITERIA specifies user preferences for dependency solving. The
374 default value depends on the solver version, use `config report' to
375 know the current setting. See also option --criteria.
376
377 OPAMCUDFFILE save the cudf graph to file-actions-explicit.dot.
378
379 OPAMCUDFTRIM controls the filtering of unrelated packages during CUDF
380 preprocessing.
381
382 OPAMCURL can be used to select a given 'curl' program. See OPAMFETCH
383 for more options.
384
385 OPAMDEBUG see options `--debug' and `--debug-level'.
386
387 OPAMDEBUGSECTIONS if set, limits debug messages to the space-separated
388 list of sections. Sections can optionally have a specific debug level
389 (for example, CLIENT:2 or CLIENT CUDF:2), but otherwise use
390 `--debug-level'.
391
392 OPAMDIGDEPTH defines how aggressive the lookup for conflicts during
393 CUDF preprocessing is.
394
395 OPAMDOWNLOADJOBS sets the maximum number of simultaneous downloads.
396
397 OPAMDROPWORKINGDIR overrides packages previously updated with
398 --working-dir on update. Without this variable set, opam would keep
399 them unchanged unless explicitly named on the command-line.
400
401 OPAMDRYRUN see option `--dry-run'.
402
403 OPAMEDITOR sets the editor to use for opam file editing, overrides
404 $EDITOR and $VISUAL.
405
406 OPAMERRLOGLEN sets the number of log lines printed when a sub-process
407 fails. 0 to print all.
408
409 OPAMEXTERNALSOLVER see option `--solver'.
410
411 OPAMFAKE see option `--fake'.
412
413 OPAMFETCH specifies how to download files: either `wget', `curl' or a
414 custom command where variables %{url}%, %{out}%, %{retry}%,
415 %{compress}% and %{checksum}% will be replaced. Overrides the
416 'download-command' value from the main config file.
417
418 OPAMFIXUPCRITERIA same as OPAMUPGRADECRITERIA, but specific to fixup.
419
420 OPAMIGNORECONSTRAINTS see install option `--ignore-constraints-on'.
421
422 OPAMIGNOREPINDEPENDS see option `--ignore-pin-depends'.
423
424 OPAMINPLACEBUILD see option `--inplace-build'.
425
426 OPAMJOBS sets the maximum number of parallel workers to run.
427
428 OPAMJSON log json output to the given file (use character `%' to index
429 the files).
430
431 OPAMKEEPBUILDDIR see install option `--keep-build-dir'.
432
433 OPAMKEEPLOGS tells opam to not remove some temporary command logs and
434 some backups. This skips some finalisers and may also help to get more
435 reliable backtraces.
436
437 OPAMLOCKED combination of `--locked' and `--lock-suffix' options.
438
439 OPAMLOGS logdir sets log directory, default is a temporary directory in
440 /tmp
441
442 OPAMMAKECMD set the system make command to use.
443
444 OPAMMERGEOUT merge process outputs, stderr on stdout.
445
446 OPAMNO answer no to any question asked, see options `--no` and
447 `--confirm-level`. OPAMNO is ignored if either OPAMCONFIRMLEVEL or
448 OPAMYES is set.
449
450 OPAMNOAGGREGATE with `opam admin check', don't aggregate packages.
451
452 OPAMNOASPCUD Deprecated.
453
454 OPAMNOAUTOUPGRADE disables automatic internal upgrade of repositories
455 in an earlier format to the current one, on 'update' or 'init'.
456
457 OPAMNOCHECKSUMS enables option --no-checksums when available.
458
459 OPAMNODEPEXTS disables system dependencies handling, see option
460 `--no-depexts'.
461
462 OPAMNOENVNOTICE Internal.
463
464 OPAMNOSELFUPGRADE see option `--no-self-upgrade'
465
466 OPAMPINKINDAUTO sets whether version control systems should be detected
467 when pinning to a local path. Enabled by default since 1.3.0.
468
469 OPAMPRECISETRACKING fine grain tracking of directories.
470
471 OPAMPREPRO set this to false to disable CUDF preprocessing. Less
472 efficient, but might help debugging solver issue.
473
474 OPAMREQUIRECHECKSUMS Enables option `--require-checksums' when
475 available (e.g. for `opam install').
476
477 OPAMRETRIES sets the number of tries before failing downloads.
478
479 OPAMREUSEBUILDDIR see option `--reuse-build-dir'.
480
481 OPAMROOT see option `--root'. This is automatically set by `opam env
482 --root=DIR --set-root'.
483
484 OPAMROOTISOK don't complain when running as root.
485
486 OPAMSAFE see option `--safe'.
487
488 OPAMSHOW see option `--show'.
489
490 OPAMSKIPUPDATE see option `--skip-updates'.
491
492 OPAMSKIPVERSIONCHECKS bypasses some version checks. Unsafe, for
493 compatibility testing only.
494
495 OPAMSOLVERALLOWSUBOPTIMAL (default `true') allows some solvers to still
496 return a solution when they reach timeout; while the solution remains
497 assured to be consistent, there is no guarantee in this case that it
498 fits the expected optimisation criteria. If `true', opam willcontinue
499 with a warning, if `false' a timeout is an error. Currently only the
500 builtin-z3 backend handles this degraded case.
501
502 OPAMSOLVERTIMEOUT change the time allowance of the solver. Default is
503 60.0, set to 0 for unlimited. Note that all solvers may not support
504 this option.
505
506 OPAMSTATS display stats at the end of command.
507
508 OPAMSTATUSLINE display a dynamic status line showing what's currently
509 going on on the terminal. (one of one of always, never or auto)
510
511 OPAMSTRICT fail on inconsistencies (file reading, switch import, etc.).
512
513 OPAMSWITCH see option `--switch'. Automatically set by `opam env
514 --switch=SWITCH --set-switch'.
515
516 OPAMUNLOCKBASE see install option `--unlock-base'.
517
518 OPAMUPGRADECRITERIA specifies user preferences for dependency solving
519 when performing an upgrade. Overrides OPAMCRITERIA in upgrades if both
520 are set. See also option --criteria.
521
522 OPAMUSEINTERNALSOLVER see option `--use-internal-solver'.
523
524 OPAMUSEOPENSSL force openssl use for hash computing.
525
526 OPAMUTF8 use UTF8 characters in output (one of one of always, never or
527 auto). By default `auto', which is determined from the locale).
528
529 OPAMUTF8MSGS use extended UTF8 characters (camels) in opam messages.
530 Implies OPAMUTF8. This is set by default on OSX only.
531
532 OPAMVALIDATIONHOOK if set, uses the `%{hook%}' command to validate an
533 opam repository update.
534
535 OPAMVERBOSE see option `--verbose'.
536
537 OPAMVERSIONLAGPOWER do not use.
538
539 OPAMWITHDOC see install option `--with-doc'.
540
541 OPAMWITHTEST see install option `--with-test.
542
543 OPAMWORKINGDIR see option `--working-dir'.
544
545 OPAMYES see options `--yes' and `--confirm-level`. OPAMYES has has
546 priority over OPAMNO and is ignored if OPAMCONFIRMLEVEL is set.
547
548 OPAMVAR_var overrides the contents of the variable var when
549 substituting `%{var}%` strings in `opam` files.
550
551 OPAMVAR_package_var overrides the contents of the variable package:var
552 when substituting `%{package:var}%` strings in `opam` files.
553
555 All scripts and programmatic invocations of opam should use `--cli' in
556 order to ensure that they work seamlessly with future versions of the
557 opam client. Additionally, blog posts or other documentation can
558 benefit, as it prevents information from becoming stale.
559
560 Although opam only supports roots (~/.opam/) for the current version,
561 it does provide backwards compatibility for its command-line interface.
562
563 Since CLI version support was only added in opam 2.1, use OPAMCLI to
564 select 2.0 support (as opam 2.0 will just ignore it), and `--cli=2.1'
565 for 2.1 (or later) versions, since an environment variable controlling
566 the parsing of syntax is brittle. To this end, opam displays a warning
567 if OPAMCLI specifies a valid version other than 2.0, and also if
568 `--cli=2.0' is specified.
569
570 The command-line version is selected by using the `--cli' option or the
571 OPAMCLI environment variable. `--cli' may be specified morethan once,
572 where the last instance takes precedence. OPAMCLI is only inspected if
573 `--cli' is not given.
574
576 As an exception to the following, the `exec' command returns 127 if the
577 command was not found or couldn't be executed, and the command's exit
578 value otherwise.
579
580 0 Success, or true for boolean queries.
581
582 1 False. Returned when a boolean return value is expected, e.g. when
583 running with --check, or for queries like opam lint.
584
585 2 Bad command-line arguments, or command-line arguments pointing to
586 an invalid context (e.g. file not following the expected format).
587
588 5 Not found. You requested something (package, version, repository,
589 etc.) that couldn't be found.
590
591 10 Aborted. The operation required confirmation, which wasn't given.
592
593 15 Could not acquire the locks required for the operation.
594
595 20 There is no solution to the user request. This can be caused by
596 asking to install two incompatible packages, for example.
597
598 30 Error in package definition, or other metadata files. Using
599 --strict raises this error more often.
600
601 31 Package script error. Some package operations were unsuccessful.
602 This may be an error in the packages or an incompatibility with
603 your system. This can be a partial error.
604
605 40 Sync error. Could not fetch some remotes from the network. This can
606 be a partial error.
607
608 50 Configuration error. Opam or system configuration doesn't allow
609 operation, and needs fixing.
610
611 60 Solver failure. The solver failed to return a sound answer. It can
612 be due to a broken external solver, or an error in solver
613 configuration.
614
615 99 Internal error. Something went wrong, likely due to a bug in opam
616 itself.
617
618 130 User interrupt. SIGINT was received, generally due to the user
619 pressing Ctrl-C.
620
622 See https://opam.ocaml.org/doc.
623
625 Vincent Bernardoff <vb@luminar.eu.org>
626 Raja Boujbel <raja.boujbel@ocamlpro.com>
627 Roberto Di Cosmo <roberto@dicosmo.org>
628 Thomas Gazagnaire <thomas@gazagnaire.org>
629 Louis Gesbert <louis.gesbert@ocamlpro.com>
630 Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr>
631 Anil Madhavapeddy <anil@recoil.org>
632 Guillem Rieu <guillem.rieu@ocamlpro.com>
633 Ralf Treinen <ralf.treinen@pps.jussieu.fr>
634 Frederic Tuong <tuong@users.gforge.inria.fr>
635
637 Check bug reports at https://github.com/ocaml/opam/issues.
638
639
640
641Opam 2.1.3 OPAM-INSTALL(1)