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
227 `auto'.
228
229 --confirm-level=LEVEL
230 Confirmation level, LEVEL must be one of `ask', `no', `yes' or
231 `unsafe-yes'. Can be specified more than once. If --yes or --no are
232 also given, the value of the last --confirm-level is taken into
233 account. This is equivalent to setting $OPAMCONFIRMLEVEL`.
234
235 --criteria=CRITERIA
236 Specify user preferences for dependency solving for this run.
237 Overrides both $OPAMCRITERIA and $OPAMUPGRADECRITERIA. For details
238 on the supported language, and the external solvers available, see
239 http://opam.ocaml.org/doc/External_solvers.html. A general guide to
240 using solver preferences can be found at
241 http://www.dicosmo.org/Articles/usercriteria.pdf.
242
243 --cudf=FILENAME
244 Debug option: Save the CUDF requests sent to the solver to
245 FILENAME-<n>.cudf.
246
247 --debug
248 Print debug message to stderr. This is equivalent to setting
249 $OPAMDEBUG to "true".
250
251 --debug-level=LEVEL
252 Like --debug, but allows specifying the debug level (--debug sets
253 it to 1). Equivalent to setting $OPAMDEBUG to a positive integer.
254
255 --git-version
256 Print the git version of opam, if set (i.e. you are using a
257 development version), and exit.
258
259 --help[=FMT] (default=auto)
260 Show this help in format FMT. The value FMT must be one of `auto',
261 `pager', `groff' or `plain'. With `auto', the format is `pager` or
262 `plain' whenever the TERM env var is `dumb' or undefined.
263
264 --ignore-pin-depends
265 Ignore extra pins required by packages that get pinned, either
266 manually through opam pin or through opam install DIR. This is
267 equivalent to setting IGNOREPINDEPENDS=true.
268
269 --json=FILENAME
270 Save the results of the opam run in a computer-readable file. If
271 the filename contains the character `%', it will be replaced by an
272 index that doesn't overwrite an existing file. Similar to setting
273 the $OPAMJSON variable.
274
275 --no-aspcud
276 Removed in 2.1.
277
278 --no-auto-upgrade
279 When configuring or updating a repository that is written for an
280 earlier opam version (1.2), opam internally converts it to the
281 current format. This disables this behaviour. Note that
282 repositories should define their format version in a 'repo' file at
283 their root, or they will be assumed to be in the older format. It
284 is, in any case, preferable to upgrade the repositories manually
285 using opam admin upgrade [--mirror URL] when possible.
286
287 --no-self-upgrade
288 Opam will replace itself with a newer binary found at OPAMROOT/opam
289 if present. This disables this behaviour.
290
291 -q, --quiet
292 Disables --verbose.
293
294 --root=ROOT
295 Use ROOT as the current root path. This is equivalent to setting
296 $OPAMROOT to ROOT.
297
298 --safe, --readonly
299 Make sure nothing will be automatically updated or rewritten.
300 Useful for calling from completion scripts, for example. Will fail
301 whenever such an operation is needed ; also avoids waiting for
302 locks, skips interactive questions and overrides the $OPAMDEBUG
303 variable. This is equivalent to set environment variable $OPAMSAFE.
304
305 --solver=CMD
306 Specify the CUDF solver to use for resolving package installation
307 problems. This is either a predefined solver (this version of opam
308 supports builtin-mccs+lp(), builtin-mccs+glpk,
309 builtin-dummy-z3-solver, builtin-dummy-0install-solver, aspcud,
310 mccs, aspcud-old, packup), or a custom command that should contain
311 the variables %{input}%, %{output}%, %{criteria}%, and optionally
312 %{timeout}%. This is equivalent to setting $OPAMEXTERNALSOLVER.
313
314 --strict
315 Fail whenever an error is found in a package definition or a
316 configuration file. The default is to continue silently if
317 possible.
318
319 --switch=SWITCH
320 Use SWITCH as the current compiler switch. This is equivalent to
321 setting $OPAMSWITCH to SWITCH.
322
323 --use-internal-solver
324 Disable any external solver, and use the built-in one (this
325 requires that opam has been compiled with a built-in solver). This
326 is equivalent to setting $OPAMNOASPCUD or $OPAMUSEINTERNALSOLVER.
327
328 -v, --verbose
329 Be more verbose. One -v shows all package commands, repeat to also
330 display commands called internally (e.g. tar, curl, patch etc.)
331 Repeating n times is equivalent to setting $OPAMVERBOSE to "n".
332
333 --version
334 Show version information.
335
336 -w, --working-dir
337 Whenever updating packages that are bound to a local,
338 version-controlled directory, update to the current working state
339 of their source instead of the last committed state, or the ref
340 they are pointing to. As source directory is copied as it is, if it
341 isn't clean it may result on a opam build failure.This only affects
342 packages explicitly listed on the command-line.It can also be set
343 with $OPAMWORKINGDIR.
344
346 Opam makes use of the environment variables listed here. Boolean
347 variables should be set to "0", "no", "false" or the empty string to
348 disable, "1", "yes" or "true" to enable.
349
350 OPAMALLPARENS surround all filters with parenthesis.
351
352 OPAMASSUMEDEPEXTS see option `--assume-depexts'.
353
354 OPAMAUTOREMOVE see remove option `--auto-remove'.
355
356 OPAMBESTEFFORT see option `--best-effort'.
357
358 OPAMBESTEFFORTPREFIXCRITERIA sets the string that must be prepended to
359 the criteria when the `--best-effort' option is set, and is expected to
360 maximise the `opam-query' property in the solution.
361
362 OPAMBUILDDOC Removed in 2.1.
363
364 OPAMBUILDTEST Removed in 2.1.
365
366 OPAMCLI see option `--cli'.
367
368 OPAMCOLOR when set to always or never, sets a default value for the
369 `--color' option.
370
371 OPAMCONFIRMLEVEL see option `--confirm-level`. OPAMCONFIRMLEVEL has
372 priority over OPAMYES and OPAMNO.
373
374 OPAMCRITERIA specifies user preferences for dependency solving. The
375 default value depends on the solver version, use `config report' to
376 know the current setting. See also option --criteria.
377
378 OPAMCUDFFILE save the cudf graph to file-actions-explicit.dot.
379
380 OPAMCUDFTRIM controls the filtering of unrelated packages during CUDF
381 preprocessing.
382
383 OPAMCURL can be used to select a given 'curl' program. See OPAMFETCH
384 for more options.
385
386 OPAMDEBUG see options `--debug' and `--debug-level'.
387
388 OPAMDEBUGSECTIONS if set, limits debug messages to the space-separated
389 list of sections. Sections can optionally have a specific debug level
390 (for example, CLIENT:2 or CLIENT CUDF:2), but otherwise use
391 `--debug-level'.
392
393 OPAMDIGDEPTH defines how aggressive the lookup for conflicts during
394 CUDF preprocessing is.
395
396 OPAMDOWNLOADJOBS sets the maximum number of simultaneous downloads.
397
398 OPAMDROPWORKINGDIR overrides packages previously updated with
399 --working-dir on update. Without this variable set, opam would keep
400 them unchanged unless explicitly named on the command-line.
401
402 OPAMDRYRUN see option `--dry-run'.
403
404 OPAMEDITOR sets the editor to use for opam file editing, overrides
405 $EDITOR and $VISUAL.
406
407 OPAMERRLOGLEN sets the number of log lines printed when a sub-process
408 fails. 0 to print all.
409
410 OPAMEXTERNALSOLVER see option `--solver'.
411
412 OPAMFAKE see option `--fake'.
413
414 OPAMFETCH specifies how to download files: either `wget', `curl' or a
415 custom command where variables %{url}%, %{out}%, %{retry}%,
416 %{compress}% and %{checksum}% will be replaced. Overrides the
417 'download-command' value from the main config file.
418
419 OPAMFIXUPCRITERIA same as OPAMUPGRADECRITERIA, but specific to fixup.
420
421 OPAMIGNORECONSTRAINTS see install option `--ignore-constraints-on'.
422
423 OPAMIGNOREPINDEPENDS see option `--ignore-pin-depends'.
424
425 OPAMINPLACEBUILD see option `--inplace-build'.
426
427 OPAMJOBS sets the maximum number of parallel workers to run.
428
429 OPAMJSON log json output to the given file (use character `%' to index
430 the files).
431
432 OPAMKEEPBUILDDIR see install option `--keep-build-dir'.
433
434 OPAMKEEPLOGS tells opam to not remove some temporary command logs and
435 some backups. This skips some finalisers and may also help to get more
436 reliable backtraces.
437
438 OPAMLOCKED combination of `--locked' and `--lock-suffix' options.
439
440 OPAMLOGS logdir sets log directory, default is a temporary directory in
441 /tmp
442
443 OPAMMAKECMD set the system make command to use.
444
445 OPAMMERGEOUT merge process outputs, stderr on stdout.
446
447 OPAMNO answer no to any question asked, see options `--no` and
448 `--confirm-level`. OPAMNO is ignored if either OPAMCONFIRMLEVEL or
449 OPAMYES is set.
450
451 OPAMNOAGGREGATE with `opam admin check', don't aggregate packages.
452
453 OPAMNOASPCUD Deprecated.
454
455 OPAMNOAUTOUPGRADE disables automatic internal upgrade of repositories
456 in an earlier format to the current one, on 'update' or 'init'.
457
458 OPAMNOCHECKSUMS enables option --no-checksums when available.
459
460 OPAMNODEPEXTS disables system dependencies handling, see option
461 `--no-depexts'.
462
463 OPAMNOENVNOTICE Internal.
464
465 OPAMNOSELFUPGRADE see option `--no-self-upgrade'
466
467 OPAMPINKINDAUTO sets whether version control systems should be detected
468 when pinning to a local path. Enabled by default since 1.3.0.
469
470 OPAMPRECISETRACKING fine grain tracking of directories.
471
472 OPAMPREPRO set this to false to disable CUDF preprocessing. Less
473 efficient, but might help debugging solver issue.
474
475 OPAMREQUIRECHECKSUMS Enables option `--require-checksums' when
476 available (e.g. for `opam install').
477
478 OPAMRETRIES sets the number of tries before failing downloads.
479
480 OPAMREUSEBUILDDIR see option `--reuse-build-dir'.
481
482 OPAMROOT see option `--root'. This is automatically set by `opam env
483 --root=DIR --set-root'.
484
485 OPAMROOTISOK don't complain when running as root.
486
487 OPAMSAFE see option `--safe'.
488
489 OPAMSHOW see option `--show'.
490
491 OPAMSKIPUPDATE see option `--skip-updates'.
492
493 OPAMSKIPVERSIONCHECKS bypasses some version checks. Unsafe, for
494 compatibility testing only.
495
496 OPAMSOLVERALLOWSUBOPTIMAL (default `true') allows some solvers to still
497 return a solution when they reach timeout; while the solution remains
498 assured to be consistent, there is no guarantee in this case that it
499 fits the expected optimisation criteria. If `true', opam willcontinue
500 with a warning, if `false' a timeout is an error. Currently only the
501 builtin-z3 backend handles this degraded case.
502
503 OPAMSOLVERTIMEOUT change the time allowance of the solver. Default is
504 60.0, set to 0 for unlimited. Note that all solvers may not support
505 this option.
506
507 OPAMSTATS display stats at the end of command.
508
509 OPAMSTATUSLINE display a dynamic status line showing what's currently
510 going on on the terminal. (one of one of `always', `never' or `auto')
511
512 OPAMSTRICT fail on inconsistencies (file reading, switch import, etc.).
513
514 OPAMSWITCH see option `--switch'. Automatically set by `opam env
515 --switch=SWITCH --set-switch'.
516
517 OPAMUNLOCKBASE see install option `--unlock-base'.
518
519 OPAMUPGRADECRITERIA specifies user preferences for dependency solving
520 when performing an upgrade. Overrides OPAMCRITERIA in upgrades if both
521 are set. See also option --criteria.
522
523 OPAMUSEINTERNALSOLVER see option `--use-internal-solver'.
524
525 OPAMUSEOPENSSL force openssl use for hash computing.
526
527 OPAMUTF8 use UTF8 characters in output (one of one of `always', `never'
528 or `auto'). By default `auto', which is determined from the locale).
529
530 OPAMUTF8MSGS use extended UTF8 characters (camels) in opam messages.
531 Implies OPAMUTF8. This is set by default on OSX only.
532
533 OPAMVALIDATIONHOOK if set, uses the `%{hook%}' command to validate an
534 opam repository update.
535
536 OPAMVERBOSE see option `--verbose'.
537
538 OPAMVERSIONLAGPOWER do not use.
539
540 OPAMWITHDOC see install option `--with-doc'.
541
542 OPAMWITHTEST see install option `--with-test.
543
544 OPAMWORKINGDIR see option `--working-dir'.
545
546 OPAMYES see options `--yes' and `--confirm-level`. OPAMYES has has
547 priority over OPAMNO and is ignored if OPAMCONFIRMLEVEL is set.
548
549 OPAMVAR_var overrides the contents of the variable var when
550 substituting `%{var}%` strings in `opam` files.
551
552 OPAMVAR_package_var overrides the contents of the variable package:var
553 when substituting `%{package:var}%` strings in `opam` files.
554
556 All scripts and programmatic invocations of opam should use `--cli' in
557 order to ensure that they work seamlessly with future versions of the
558 opam client. Additionally, blog posts or other documentation can
559 benefit, as it prevents information from becoming stale.
560
561 Although opam only supports roots (~/.opam/) for the current version,
562 it does provide backwards compatibility for its command-line interface.
563
564 Since CLI version support was only added in opam 2.1, use OPAMCLI to
565 select 2.0 support (as opam 2.0 will just ignore it), and `--cli=2.1'
566 for 2.1 (or later) versions, since an environment variable controlling
567 the parsing of syntax is brittle. To this end, opam displays a warning
568 if OPAMCLI specifies a valid version other than 2.0, and also if
569 `--cli=2.0' is specified.
570
571 The command-line version is selected by using the `--cli' option or the
572 OPAMCLI environment variable. `--cli' may be specified morethan once,
573 where the last instance takes precedence. OPAMCLI is only inspected if
574 `--cli' is not given.
575
577 As an exception to the following, the `exec' command returns 127 if the
578 command was not found or couldn't be executed, and the command's exit
579 value otherwise.
580
581 0 Success, or true for boolean queries.
582
583 1 False. Returned when a boolean return value is expected, e.g. when
584 running with --check, or for queries like opam lint.
585
586 2 Bad command-line arguments, or command-line arguments pointing to
587 an invalid context (e.g. file not following the expected format).
588
589 5 Not found. You requested something (package, version, repository,
590 etc.) that couldn't be found.
591
592 10 Aborted. The operation required confirmation, which wasn't given.
593
594 15 Could not acquire the locks required for the operation.
595
596 20 There is no solution to the user request. This can be caused by
597 asking to install two incompatible packages, for example.
598
599 30 Error in package definition, or other metadata files. Using
600 --strict raises this error more often.
601
602 31 Package script error. Some package operations were unsuccessful.
603 This may be an error in the packages or an incompatibility with
604 your system. This can be a partial error.
605
606 40 Sync error. Could not fetch some remotes from the network. This can
607 be a partial error.
608
609 50 Configuration error. Opam or system configuration doesn't allow
610 operation, and needs fixing.
611
612 60 Solver failure. The solver failed to return a sound answer. It can
613 be due to a broken external solver, or an error in solver
614 configuration.
615
616 99 Internal error. Something went wrong, likely due to a bug in opam
617 itself.
618
619 130 User interrupt. SIGINT was received, generally due to the user
620 pressing Ctrl-C.
621
623 See https://opam.ocaml.org/doc.
624
626 Vincent Bernardoff <vb@luminar.eu.org>
627 Raja Boujbel <raja.boujbel@ocamlpro.com>
628 Roberto Di Cosmo <roberto@dicosmo.org>
629 Thomas Gazagnaire <thomas@gazagnaire.org>
630 Louis Gesbert <louis.gesbert@ocamlpro.com>
631 Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr>
632 Anil Madhavapeddy <anil@recoil.org>
633 Guillem Rieu <guillem.rieu@ocamlpro.com>
634 Ralf Treinen <ralf.treinen@pps.jussieu.fr>
635 Frederic Tuong <tuong@users.gforge.inria.fr>
636
638 Check bug reports at https://github.com/ocaml/opam/issues.
639
640
641
642Opam 2.1.1 OPAM-INSTALL(1)