1opam-switch(1)                    Opam Manual                   opam-switch(1)
2
3
4

NAME

6       opam-switch - Manage multiple installation prefixes.
7

SYNOPSIS

9       opam switch [OPTION]... [COMMAND] [ARG]...
10

DESCRIPTION

12       This command is used to manage "switches", which are independent
13       installation prefixes with their own compiler and sets of installed and
14       pinned packages. This is typically useful to have different versions of
15       the compiler available at once.
16
17       Use opam switch create to create a new switch, and opam switch set to
18       set the currently active switch. Without argument, lists installed
19       switches, with one switch argument, defaults to set.
20
21       Switch handles SWITCH can be either a plain name, for switches that
22       will be held inside ~/.opam, or a directory name, which in that case is
23       the directory where the switch prefix will be installed, as _opam. Opam
24       will automatically select a switch by that name found in the current
25       directory or its parents, unless OPAMSWITCH is set or --switch is
26       specified. When creating a directory switch, if package definitions are
27       found locally, the user is automatically prompted to install them after
28       the switch is created unless --no-install is specified.
29
30       opam switch set sets the default switch globally, but it is also
31       possible to select a switch in a given shell session, using the
32       environment. For that, use eval $(opam env --switch=SWITCH
33       --set-switch).
34

COMMANDS

36       Without argument, defaults to list.
37
38       SWITCH
39           With a SWITCH argument, defaults to set SWITCH.
40
41       create SWITCH [COMPILER]
42           Create a new switch, and install the given compiler there. SWITCH
43           can be a plain name, or a directory, absolute or relative, in which
44           case a local switch is created below the given directory. COMPILER,
45           if omitted, defaults to SWITCH if it is a plain name, unless
46           --packages or --empty is specified. When creating a local switch,
47           and none of these options are present, the compiler is chosen
48           according to the configuration default (see opam-init(1)). If the
49           chosen directory contains package definitions, a compatible
50           compiler is searched within the default selection, and the packages
51           will automatically get installed.
52
53       set SWITCH
54           Set the currently active switch, among the installed switches.
55
56       remove SWITCH
57           Remove the given switch from disk.
58
59       export FILE
60           Save the current switch state to a file. If --full is specified, it
61           includes the metadata of all installed packages
62
63       import FILE
64           Import a saved switch state. If --switch is specified and doesn't
65           point to an existing switch, the switch will be created for the
66           import.
67
68       reinstall [SWITCH]
69           Reinstall the given compiler switch and all its packages.
70
71       list
72           Lists installed switches.
73
74       list-available [PATTERN]
75           Lists base packages that can be used to create a new switch, i.e.
76           packages with the compiler flag set. If no pattern is supplied, all
77           versions are shown.
78
79       show
80           Prints the name of the current switch.
81
82       set-base PACKAGES
83           Sets the packages forming the immutable base for the selected
84           switch, overriding the current setting.
85
86       set-description STRING
87           Sets the description for the selected switch
88
89       link SWITCH [DIR]
90           Sets a local alias for a given switch, so that the switch gets
91           automatically selected whenever in that directory or a descendant.
92
93       install SWITCH
94           Deprecated alias for 'create'.
95

OPTIONS

97       --deps-only
98           When creating a local switch in a project directory (i.e. a
99           directory containing opam package definitions), install the
100           dependencies of the project but not the project itself.
101
102       --description=STRING
103           Attach the given description to a switch when creating it. Use the
104           set-description subcommand to modify the description of an existing
105           switch.
106
107       --empty
108           Allow creating an empty (without compiler) switch.
109
110       --full
111           When exporting, include the metadata of all installed packages,
112           allowing to re-import even if they don't exist in the repositories
113           (the default is to include only the metadata of pinned packages).
114
115       -j JOBS, --jobs=JOBS
116           Set the maximal number of concurrent jobs to use. The default value
117           is calculated from the number of cores. You can also set it using
118           the $OPAMJOBS environment variable.
119
120       --no-install
121           When creating a local switch, don't look for any local package
122           definitions to install.
123
124       --no-switch
125           Don't automatically select newly installed switches.
126
127       --packages=PACKAGES
128           When installing a switch, explicitly define the set of packages to
129           set as the compiler.
130
131       --repositories=REPOS
132           When creating a new switch, use the given selection of repositories
133           instead of the default. REPOS should be a comma-separated list of
134           either already registered repository names (configured through e.g.
135           opam repository add --dont-select), or NAME=URL bindings, in which
136           case NAME should not be registered already to a different URL, and
137           the new repository will be registered. See opam repository for more
138           details. This option also affects list-available.
139
140       -s, --short
141           Output raw lists of names, one per line, skipping any details.
142

PACKAGE BUILD OPTIONS

144       -b, --keep-build-dir
145           Keep the build directories after compiling packages. This is
146           equivalent to setting $OPAMKEEPBUILDDIR to "true".
147
148       -d, --with-doc, --build-doc
149           Build the package documentation. This only affects packages listed
150           on the command-line. The --build-doc form is deprecated as this
151           does also installation. This is equivalent to setting $OPAMWITHDOC
152           (or the deprecated $OPAMBUILDDOC) to "true".
153
154       --dry-run
155           Simulate the command, but don't actually perform any changes.
156
157       --fake
158           This option registers the actions into the opam database, without
159           actually performing them. WARNING: This option is dangerous and
160           likely to break your opam environment. You probably want
161           `--dry-run'. You've been warned.
162
163       --ignore-constraints-on[=PACKAGES] (default=)
164           Forces opam to ignore version constraints on all dependencies to
165           the listed packages. This can be used to test compatibility, but
166           expect builds to break when using this. Note that version
167           constraints on optional dependencies and conflicts are unaffected.
168
169       --inplace-build
170           When compiling a package which has its source bound to a local
171           directory, process the build and install actions directly in that
172           directory, rather than in a clean copy handled by opam. This only
173           affects packages that are explicitly listed on the command-line.
174           This is equivalent to setting $OPAMINPLACEBUILD to "true".
175
176       --locked[=SUFFIX] (default=locked)
177           In commands that use opam files found from pinned sources, if a
178           variant of the file with an added .SUFFIX extension is found (e.g.
179           foo.opam.locked besides foo.opam), that will be used instead. This
180           is typically useful to offer a more specific set of dependencies
181           and reproduce similar build contexts, hence the name. The opam lock
182           plugin can be used to generate such files, based on the versions of
183           the dependencies currently installed on the host. This is
184           equivalent to setting the $OPAMLOCK environment variable. Note that
185           this option doesn't generally affect already pinned packages.
186
187       -m MAKE, --make=MAKE
188           Use MAKE as the default 'make' command. Deprecated: use opam config
189           set[-global] make MAKE instead. Has no effect if the make variable
190           is defined.
191
192       --no-checksums
193           Do not verify the checksum of downloaded archives.This is
194           equivalent to setting $OPAMNOCHECKSUMS to "true".
195
196       --require-checksums
197           Reject the installation of packages that don't provide a checksum
198           for the upstream archives. This is equivalent to setting
199           $OPAMREQUIRECHECKSUMS to "true".
200
201       --reuse-build-dir
202           Reuse existing build directories (kept by using --keep-build-dir),
203           instead of compiling from a fresh clone of the source. This can be
204           faster, but also lead to failures if the build systems of the
205           packages don't handle upgrades of dependencies well. This is
206           equivalent to setting $OPAMREUSEBUILDDIR to "true".
207
208       --show-actions
209           Call the solver and display the actions. Don't perform any changes.
210
211       --skip-updates
212           When running an install, upgrade or reinstall on source-pinned
213           packages, they are normally updated from their origin first. This
214           flag disables that behaviour and will keep them to their version in
215           cache.
216
217       -t, --with-test, --build-test
218           Build and run the package unit-tests. This only affects packages
219           listed on the command-line. The --build-test form is deprecated as
220           this also affects installation. This is equivalent to setting
221           $OPAMWITHTEST (or the deprecated $OPAMBUILDTEST) to "true".
222
223       --unlock-base
224           Allow changes to the packages set as switch base (typically, the
225           main compiler). Use with caution.
226

COMMON OPTIONS

228       These options are common to all commands.
229
230       --best-effort
231           Don't fail if all requested packages can't be installed: try to
232           install as many as possible. Note that not all external solvers may
233           support this option (recent versions of aspcud or mccs should).
234
235       --color=WHEN
236           Colorize the output. WHEN must be one of `always', `never' or
237           `auto'.
238
239       --criteria=CRITERIA
240           Specify user preferences for dependency solving for this run.
241           Overrides both $OPAMCRITERIA and $OPAMUPGRADECRITERIA. For details
242           on the supported language, and the external solvers available, see
243           http://opam.ocaml.org/doc/Specifying_Solver_Preferences.html. A
244           general guide to using solver preferences can be found at
245           http://www.dicosmo.org/Articles/usercriteria.pdf.
246
247       --cudf=FILENAME
248           Debug option: Save the CUDF requests sent to the solver to
249           FILENAME-<n>.cudf.
250
251       --debug
252           Print debug message to stderr. This is equivalent to setting
253           $OPAMDEBUG to "true".
254
255       --debug-level=LEVEL
256           Like --debug, but allows specifying the debug level (--debug sets
257           it to 1). Equivalent to setting $OPAMDEBUG to a positive integer.
258
259       --git-version
260           Print the git version of opam, if set (i.e. you are using a
261           development version), and exit.
262
263       --help[=FMT] (default=auto)
264           Show this help in format FMT. The value FMT must be one of `auto',
265           `pager', `groff' or `plain'. With `auto', the format is `pager` or
266           `plain' whenever the TERM env var is `dumb' or undefined.
267
268       --ignore-pin-depends
269           Ignore extra pins required by packages that get pinned, either
270           manually through opam pin or through opam install DIR. This is
271           equivalent to setting IGNOREPINDEPENDS=true.
272
273       --json=FILENAME
274           Save the results of the opam run in a computer-readable file. If
275           the filename contains the character `%', it will be replaced by an
276           index that doesn't overwrite an existing file. Similar to setting
277           the $OPAMJSON variable.
278
279       --no-auto-upgrade
280           When configuring or updating a repository that is written for an
281           earlier opam version (1.2), opam internally converts it to the
282           current format. This disables this behaviour. Note that
283           repositories should define their format version in a 'repo' file at
284           their root, or they will be assumed to be in the older format. It
285           is, in any case, preferable to upgrade the repositories manually
286           using opam admin upgrade [--mirror URL] when possible.
287
288       --no-self-upgrade
289           Opam will replace itself with a newer binary found at OPAMROOT/opam
290           if present. This disables this behaviour.
291
292       -q, --quiet
293           Disables --verbose.
294
295       --root=ROOT
296           Use ROOT as the current root path. This is equivalent to setting
297           $OPAMROOT to ROOT.
298
299       --safe, --readonly
300           Make sure nothing will be automatically updated or rewritten.
301           Useful for calling from completion scripts, for example. Will fail
302           whenever such an operation is needed ; also avoids waiting for
303           locks, skips interactive questions and overrides the $OPAMDEBUG
304           variable.
305
306       --solver=CMD
307           Specify the CUDF solver to use for resolving package installation
308           problems. This is either a predefined solver (this version of opam
309           supports builtin-mccs+lp(), builtin-mccs+glpk, aspcud, mccs,
310           aspcud-old, packup), or a custom command that should contain the
311           variables %{input}%, %{output}%, %{criteria}%, and optionally
312           %{timeout}%.
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, --no-aspcud
324           Disable any external solver, and use the built-in one (this
325           requires that opam has been compiled with a built-in solver).
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. This only affects packages explicitly listed
340           on the command-line.
341
342       -y, --yes
343           Answer yes to all yes/no questions without prompting. This is
344           equivalent to setting $OPAMYES to "true".
345

ENVIRONMENT VARIABLES

347       Opam makes use of the environment variables listed here. Boolean
348       variables should be set to "0", "no", "false" or the empty string to
349       disable, "1", "yes" or "true" to enable.
350
351       OPAMCOLOR, when set to always or never, sets a default value for the
352       --color option.
353
354       OPAMCRITERIA specifies user preferences for dependency solving. The
355       default value depends on the solver version, use `config report` to
356       know the current setting. See also option --criteria
357
358       OPAMCURL can be used to select a given 'curl' program. See OPAMFETCH
359       for more options.
360
361       OPAMDEBUG see options `--debug' and `--debug-level'.
362
363       OPAMDOWNLOADJOBS sets the maximum number of simultaneous downloads.
364
365       OPAMERRLOGLEN sets the number of log lines printed when a sub-process
366       fails. 0 to print all.
367
368       OPAMEXTERNALSOLVER see option `--solver'.
369
370       OPAMFETCH specifies how to download files: either `wget', `curl' or a
371       custom command where variables %{url}%, %{out}%, %{retry}%,
372       %{compress}% and %{checksum}% will be replaced. Overrides the
373       'download-command' value from the main config file.
374
375       OPAMJOBS sets the maximum number of parallel workers to run.
376
377       OPAMJSON log json output to the given file (use character `%' to index
378       the files)
379
380       OPAMLOCK see option `--lock'.
381
382       OPAMNOAUTOUPGRADE disables automatic internal upgrade of repositories
383       in an earlier format to the current one, on 'update' or 'init'.
384
385       OPAMKEEPLOGS tells opam to not remove some temporary command logs and
386       some backups. This skips some finalisers and may also help to get more
387       reliable backtraces
388
389       OPAMLOCKRETRIES sets the number of tries after which OPAM gives up
390       acquiring its lock and fails. <= 0 means infinite wait.
391
392       OPAMNO answer no to any question asked.
393
394       OPAMNOASPCUD see option `--no-aspcud'.
395
396       OPAMNOSELFUPGRADE see option `--no-self-upgrade'.
397
398       OPAMPINKINDAUTO sets whether version control systems should be detected
399       when pinning to a local path. Enabled by default since 1.3.0.
400
401       OPAMREQUIRECHECKSUMS Enables option `--require-checksums' when
402       available (e.g. for `opam install`).
403
404       OPAMRETRY sets the number of tries before failing downloads.
405
406       OPAMROOT see option `--root'. This is automatically set by `opam env
407       --root=DIR --set-root'.
408
409       OPAMROOTISOK don't complain when running as root.
410
411       OPAMSAFE see option `--safe'
412
413       OPAMSKIPVERSIONCHECKS bypasses some version checks. Unsafe, for
414       compatibility testing only.
415
416       OPAMSOLVERTIMEOUT change the time allowance of the solver. Default is
417       60.0, set to 0 for unlimited. Note that all solvers may not support
418       this option.
419
420       OPAMSTATUSLINE display a dynamic status line showing what's currently
421       going on on the terminal. (one of one of `always', `never' or `auto')
422
423       OPAMSWITCH see option `--switch'. Automatically set by `opam env
424       --switch=SWITCH --set-switch'.
425
426       OPAMUPGRADECRITERIA specifies user preferences for dependency solving
427       when performing an upgrade. Overrides OPAMCRITERIA in upgrades if both
428       are set. See also option --criteria
429
430       OPAMUSEINTERNALSOLVER see option `--use-internal-solver'.
431
432       OPAMUTF8 use UTF8 characters in output (one of one of `always', `never'
433       or `auto'). By default `auto', which is determined from the locale).
434
435       OPAMUTF8MSGS use extended UTF8 characters (camels) in opam messages.
436       Implies OPAMUTF8. This is set by default on OSX only.
437
438       OPAMVAR_var overrides the contents of the variable var when
439       substituting `%{var}%` strings in `opam` files.
440
441       OPAMVAR_package_var overrides the contents of the variable package:var
442       when substituting `%{package:var}%` strings in `opam` files.
443
444       OPAMVERBOSE see option `--verbose'.
445
446       OPAMYES see option `--yes'.
447

EXIT STATUS

449       As an exception to the following, the `exec' command returns 127 if the
450       command was not found or couldn't be executed, and the command's exit
451       value otherwise.
452
453       0   Success, or true for boolean queries.
454
455       1   False. Returned when a boolean return value is expected, e.g. when
456           running with --check, or for queries like opam lint.
457
458       2   Bad command-line arguments, or command-line arguments pointing to
459           an invalid context (e.g. file not following the expected format).
460
461       5   Not found. You requested something (package, version, repository,
462           etc.) that couldn't be found.
463
464       10  Aborted. The operation required confirmation, which wasn't given.
465
466       15  Could not acquire the locks required for the operation.
467
468       20  There is no solution to the user request. This can be caused by
469           asking to install two incompatible packages, for example.
470
471       30  Error in package definition, or other metadata files. Using
472           --strict raises this error more often.
473
474       31  Package script error. Some package operations were unsuccessful.
475           This may be an error in the packages or an incompatibility with
476           your system. This can be a partial error.
477
478       40  Sync error. Could not fetch some remotes from the network. This can
479           be a partial error.
480
481       50  Configuration error. Opam or system configuration doesn't allow
482           operation, and needs fixing.
483
484       60  Solver failure. The solver failed to return a sound answer. It can
485           be due to a broken external solver, or an error in solver
486           configuration.
487
488       99  Internal error. Something went wrong, likely due to a bug in opam
489           itself.
490
491       130 User interrupt. SIGINT was received, generally due to the user
492           pressing Ctrl-C.
493

FURTHER DOCUMENTATION

495       See https://opam.ocaml.org/doc.
496

AUTHORS

498       Vincent Bernardoff <vb@luminar.eu.org>
499       Raja Boujbel <raja.boujbel@ocamlpro.com>
500       Roberto Di Cosmo <roberto@dicosmo.org>
501       Thomas Gazagnaire <thomas@gazagnaire.org>
502       Louis Gesbert <louis.gesbert@ocamlpro.com>
503       Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr>
504       Anil Madhavapeddy <anil@recoil.org>
505       Guillem Rieu <guillem.rieu@ocamlpro.com>
506       Ralf Treinen <ralf.treinen@pps.jussieu.fr>
507       Frederic Tuong <tuong@users.gforge.inria.fr>
508

BUGS

510       Check bug reports at https://github.com/ocaml/opam/issues.
511
512
513
514Opam 2.0.1                                                      opam-switch(1)
Impressum