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