OPAM-OPTION(1)

πŸ’… OPAM-OPTION πŸ’…

okay bestie, welcome to opam-option β€” the part of the Opam Manual where we talk about Global and switch configuration options settings. yes. it's the settings page. the vibe is: you're tweaking your config, and this command is your girl 🫢


✨ SYNOPSIS ✨

opam option [--global] [OPTION]… [FIELD[(=|+=|-=)[VALUE]]]

🌸 DESCRIPTION 🌸

so like, here's the tea β˜• β€” what opam option does depends entirely on what you hand it:

  • no argument at all? it lists every single configurable field for you. window shopping. πŸ‘€
  • just a field name, FIELD? it shows you what that field's content is. simple. iconic.
  • anything else? it sets or updates that field in the global/switch configuration file. now you're doing something.

and for global configuration specifically: FIELD gets reset to its default initial value β€” like, the value it would have right after a fresh init. if you wanna peek at what that looks like, run opam init show-default-opamrc. no cap. πŸŽ€


🧚 ARGUMENTS 🧚

  • FIELD[(=|+=|-=)[VALUE]] β€” the whole drama happens here, bestie:
    • if you give only FIELD, it displays its associated value. that's it. that's the whole job. πŸ’–
    • if VALUE is absent, FIELD's value gets reverted. like an undo button but for config.
    • otherwise, its value is updated, and you get to pick the flavour of update:
      • = β€” overwrite it. (out with the old, periodt.)
      • += β€” append an element. (adding to the collection ✨)
      • -= β€” remove an element. (blocked and deleted πŸ’€)

πŸ’… OPTIONS πŸ’…

  • --global β€” Act on global configuration.

πŸ‘‘ COMMON OPTIONS πŸ‘‘

these ones are common to all commands, so you'll be seeing their faces everywhere. learn them, love them. 🌈
  • --best-effort β€” Don't fail if all requested packages can't be installed: try to install as many as possible. Note that not all external solvers may support this option (recent versions of aspcud or mccs should). This is equivalent to setting $OPAMBESTEFFORT environment variable.
  • --cli=MAJOR.MINOR (absent=2.6) β€” Use the command-line interface syntax and semantics of MAJOR.MINOR. Intended for any persistent use of opam (scripts, blog posts, etc.), any version of opam in the same MAJOR series will behave as for the specified MINOR release. The flag was not available in opam 2.0, so to select the 2.0 CLI, set the OPAMCLI environment variable to 2.0 instead of using this parameter. πŸ•°οΈ
  • --color=WHEN β€” Colorize the output. WHEN must be one of always, never or auto.
  • --confirm-level=LEVEL β€” Confirmation level, LEVEL must be one of ask, no, yes or unsafe-yes. Can be specified more than once. If --yes or --no are also given, the value of the last --confirm-level is taken into account. This is equivalent to setting $OPAMCONFIRMLEVEL`. 😭 (yes the backtick situation is a little cursed, we don't talk about it)
  • --criteria=CRITERIA β€” Specify user preferences for dependency solving for this run. Overrides $OPAMCRITERIA, $OPAMFIXUPCRITERIA and $OPAMUPGRADECRITERIA. For details on the supported language, and the external solvers available, see http://opam.ocaml.org/doc/External_solvers.html. A general guide to using solver preferences can be found at http://www.dicosmo.org/Articles/usercriteria.pdf. πŸ“š
  • --cudf=FILENAME β€” Debug option: Save the CUDF requests sent to the solver to FILENAME-<n>.cudf where <n> is the n-th call to the solver during the opam run. πŸ›
  • --debug β€” Print debug message to stderr. This is equivalent to setting $OPAMDEBUG to "true".
  • --debug-level=LEVEL β€” Like --debug, but allows specifying the debug level (--debug sets it to 1). Equivalent to setting $OPAMDEBUG to a positive integer.
  • --git-version β€” Print the git version of opam, if set (i.e. you are using a development version), and exit. πŸ”₯
  • --help[=FMT] (default=auto) β€” Show this help in format FMT. The value FMT must be one of auto, pager, groff or plain. With auto, the format is pager or plain whenever the TERM env var is dumb or undefined.
  • --ignore-pin-depends β€” Ignore extra pins required by packages that get pinned, either manually through opam pin or through opam install DIR. This is equivalent to setting IGNOREPINDEPENDS=true.
  • --json=FILENAME β€” Save the results of the opam run in a computer-readable file. If the filename contains the character %, it will be replaced by an index that doesn't overwrite an existing file. Similar to setting the $OPAMJSON variable. πŸ€–
  • --no β€” Answer no to all opam yes/no questions without prompting. See also --confirm-level. This is equivalent to setting $OPAMNO to "true".
  • --no-aspcud β€” Removed in 2.1. πŸ’€ (she's gone, bestie. don't look for her.)
  • --no-auto-upgrade β€” When configuring or updating a repository that is written for an earlier opam version (1.2), opam internally converts it to the current format. This disables this behaviour. Note that repositories should define their format version in a 'repo' file at their root, or they will be assumed to be in the older format. It is, in any case, preferable to upgrade the repositories manually using opam admin upgrade [--mirror URL] when possible.
  • --no-self-upgrade β€” Opam will replace itself with a newer binary found at OPAMROOT/opam if present. This disables this behaviour. πŸ™ˆ
  • -q, --quiet β€” Disables --verbose.
  • --root=ROOT β€” Use ROOT as the current root path. This is equivalent to setting $OPAMROOT to ROOT.
  • --safe, --readonly β€” Make sure nothing will be automatically updated or rewritten. Useful for calling from completion scripts, for example. Will fail whenever such an operation is needed; also avoids waiting for locks, skips interactive questions and overrides the $OPAMDEBUG variable. This is equivalent to set environment variable $OPAMSAFE. πŸ›‘οΈ
  • --solver=CMD β€” Specify the CUDF solver to use for resolving package installation problems. This is either a predefined solver (this version of opam supports builtin-mccs+lp(), builtin-mccs+glpk, builtin-dummy-z3-solver, builtin-0install, aspcud, mccs, aspcud-old, packup), or a custom command that should contain the variables %{input}%, %{output}%, %{criteria}%, and optionally %{timeout}%. This is equivalent to setting $OPAMEXTERNALSOLVER. ⭐
  • --strict β€” Fail whenever an error is found in a package definition or a configuration file. The default is to continue silently if possible. πŸ‘‘
  • --switch=SWITCH β€” Use SWITCH as the current compiler switch. This is equivalent to setting $OPAMSWITCH to SWITCH.
  • --use-internal-solver β€” Disable any external solver, and use the built-in one (this requires that opam has been compiled with a built-in solver). This is equivalent to setting $OPAMNOASPCUD or $OPAMUSEINTERNALSOLVER.
  • -v, --verbose β€” Be more verbose. One -v shows all package commands, repeat to also display commands called internally (e.g. tar, curl, patch etc.) Repeating n times is equivalent to setting $OPAMVERBOSE to "n". πŸ—£οΈ
  • --version β€” Show version information.
  • -w, --working-dir β€” Whenever updating packages that are bound to a local, version-controlled directory, update to the current working state of their source instead of the last committed state, or the ref they are pointing to. As source directory is copied as it is, if it isn't clean it may result on a opam build failure. This only affects packages explicitly listed on the command-line. It can also be set with $OPAMWORKINGDIR. 🧹
  • -y, --yes β€” Answer yes to all opam yes/no questions without prompting. See also --confirm-level. This is equivalent to setting $OPAMYES to "true". βœ…

πŸ¦‹ ENVIRONMENT πŸ¦‹

okok so opam reads a BUNCH of environment variables, and bestie, there are so many of them. Every single one is listed below, no skips. πŸ’–

First tho, the rules for the boolean ones: set them to "0", "no", "false" or the empty string to turn it off, and "1", "yes" or "true" to turn it on. That's the whole vibe check. ✨

  • OPAMALLPARENS β€” surround all filters with parenthesis.
  • OPAMASSUMEDEPEXTS β€” see the --assume-depexts option.
  • OPAMAUTOANSWER β€” internal use only. not for you bestie πŸ™ˆ
  • OPAMAUTOREMOVE β€” see the remove option --auto-remove.
  • OPAMBESTEFFORT β€” see the --best-effort option.
  • OPAMBESTEFFORTPREFIXCRITERIA β€” sets the string that must be prepended to the criteria when the --best-effort option is set, and it's expected to maximise the opam-query property in the solution.
  • OPAMBUILDDOC β€” Removed in 2.1. πŸ’€
  • OPAMBUILDTEST β€” Removed in 2.1. πŸ’€
  • OPAMCLI β€” see the --cli option.
  • OPAMCOLOR β€” when set to always or never, it sets a default value for the --color option.
  • OPAMCONFIRMLEVEL β€” see the --confirm-level option. OPAMCONFIRMLEVEL has priority over OPAMYES and OPAMNO. πŸ‘‘
  • OPAMCRITERIA β€” specifies user preferences for dependency solving. The default value depends on the solver version β€” use config report to know the current setting. See also the --criteria option.
  • OPAMCUDFFILE β€” save the cudf graph to file-actions-explicit.dot.
  • OPAMCUDFTRIM β€” controls the filtering of unrelated packages during CUDF preprocessing.
  • OPAMCURL β€” can be used to select a given curl program. See OPAMFETCH for more options.
  • OPAMDEBUG β€” see the --debug and --debug-level options.
  • OPAMDEBUGSECTIONS β€” if set, limits debug messages to the space-separated list of sections. Sections can optionally have a specific debug level (for example, CLIENT:2 or CLIENT CUDF:2), but otherwise use --debug-level.
  • OPAMDIGDEPTH β€” defines how aggressive the lookup for conflicts during CUDF preprocessing is.
  • OPAMDOWNLOADJOBS β€” sets the maximum number of simultaneous downloads.
  • OPAMDROPWORKINGDIR β€” overrides packages previously updated with --working-dir on update. Without this variable set, opam would keep them unchanged unless they're explicitly named on the command-line.
  • OPAMDRYRUN β€” see the --dry-run option.
  • OPAMEDITOR β€” sets the editor to use for opam file editing, and it overrides $EDITOR and $VISUAL.
  • OPAMERRLOGLEN β€” sets the number of log lines printed when a sub-process fails. 0 prints all of them.
  • OPAMEXTERNALSOLVER β€” see the --solver option.
  • OPAMFAKE β€” see the --fake option.
  • OPAMFETCH β€” specifies how to download files: either wget, curl, or a custom command where the variables %{url}%, %{out}%, %{retry}%, %{compress}% and %{checksum}% will be replaced. It overrides the download-command value from the main config file.
  • OPAMFIXUPCRITERIA β€” same as OPAMUPGRADECRITERIA, but specific to fixup and reinstall.
  • OPAMIGNOREAVAILABLE β€” see the install option --ignore-available-on.
  • OPAMIGNORECONSTRAINTS β€” see the install option --ignore-constraints-on.
  • OPAMIGNOREPINDEPENDS β€” see the --ignore-pin-depends option.
  • OPAMINPLACEBUILD β€” see the --inplace-build option.
  • OPAMJOBS β€” sets the maximum number of parallel workers to run.
  • OPAMJSON β€” log json output to the given file (use the character % to index the files).
  • OPAMKEEPBUILDDIR β€” see the install option --keep-build-dir.
  • OPAMKEEPLOGS β€” tells opam to not remove some temporary command logs and some backups. This skips some finalisers and may also help to get more reliable backtraces.
  • OPAMLOCKED β€” combination of the --locked and --lock-suffix options.
  • OPAMLOGS β€” logdir sets log directory, default is a temporary directory in /tmp.
  • OPAMMAKECMD β€” set the system make command to use.
  • OPAMMERGEOUT β€” merge process outputs, stderr on stdout.
  • OPAMNO β€” answer no to any question asked, see the --no and --confirm-level options. OPAMNO is ignored if either OPAMCONFIRMLEVEL or OPAMYES is set.
  • OPAMNOAGGREGATE β€” with opam admin check, don't aggregate packages.
  • OPAMNOASPCUD β€” Deprecated. 🫠
  • OPAMNOAUTOUPGRADE β€” disables automatic internal upgrade of repositories in an earlier format to the current one, on update or init.
  • OPAMNOCHECKSUMS β€” enables the option --no-checksums when available.
  • OPAMNODEPEXTS β€” disables system dependencies handling, see the option --no-depexts.
  • OPAMNOENVNOTICE β€” Internal.
  • OPAMNOSELFUPGRADE β€” see the option --no-self-upgrade.
  • OPAMPINKINDAUTO β€” sets whether version control systems should be detected when pinning to a local path. Enabled by default since 1.3.0.
  • OPAMPRECISETRACKING β€” fine grain tracking of directories.
  • OPAMPREPRO β€” set this to false to disable CUDF preprocessing. Less efficient, but it might help debugging solver issues.
  • OPAMREPOSITORYTARRING β€” internally store all non-vcs repositories as tar.gz files (by default, http repositories are stored as archive). This can be much faster on filesystems that don't cope well with scanning large trees. All operations are done in-memory, no I/O for scanning the repository.
  • OPAMREQUIRECHECKSUMS β€” Enables the option --require-checksums when available (e.g. for opam install).
  • OPAMRETRIES β€” sets the number of tries before failing downloads.
  • OPAMREUSEBUILDDIR β€” see the option --reuse-build-dir.
  • OPAMROOT β€” see the option --root. This is automatically set by opam env --root=DIR --set-root.
  • OPAMROOTISOK β€” don't complain when running as root.
  • OPAMSAFE β€” see the option --safe.
  • OPAMSHOW β€” see the option --show.
  • OPAMSKIPUPDATE β€” see the option --skip-updates.
  • OPAMSKIPVERSIONCHECKS β€” bypasses some version checks. Unsafe, for compatibility testing only. ⚠️
  • OPAMSOLVERALLOWSUBOPTIMAL β€” (default true) allows some solvers to still return a solution when they reach timeout; while the solution remains assured to be consistent, there is no guarantee in this case that it fits the expected optimisation criteria. If true, opam willcontinue with a warning, if false a timeout is an error. Currently only the builtin-z3 backend handles this degraded case.
  • OPAMSOLVERTIMEOUT β€” change the time allowance of the solver. Default is 60.0, set to 0 for unlimited. Note that all solvers may not support this option.
  • OPAMSOLVERTOLERANCE β€” changes the tolerance towards the solver choosing an unoptimized solution (i.e. might pull outdated packages). Typical values range from 0.0 (best solution known to the solver) to 1.0 (unoptimized solution). Default is 0.0. This option is useful in case the solver can't find a solution in a reasonable time (see $OPAMSOLVERTIMEOUT). Note that all solvers may not support this option.
  • OPAMSTATS β€” Removed in 2.4. πŸ’€
  • OPAMSTATUSLINE β€” display a dynamic status line showing what's currently going on on the terminal. (one of one of always, never or auto)
  • OPAMSTRICT β€” fail on inconsistencies (file reading, switch import, etc.).
  • OPAMSWITCH β€” see the option --switch. Automatically set by opam env --switch=SWITCH --set-switch.
  • OPAMUNLOCKBASE β€” see the install option --unlock-base.
  • OPAMUPGRADECRITERIA β€” specifies user preferences for dependency solving when performing an upgrade. Overrides OPAMCRITERIA in upgrades if both are set. See also the --criteria option.
  • OPAMUSEINTERNALSOLVER β€” see the option --use-internal-solver.
  • OPAMUSEOPENSSL β€” Removed in 2.2. πŸ’€
  • OPAMUTF8 β€” use UTF8 characters in output (one of one of always, never or auto). By default auto, which is determined from the locale).
  • OPAMUTF8MSGS β€” use extended UTF8 characters (camels) in opam messages. Implies OPAMUTF8. This is set by default on macOS only. πŸͺ
  • OPAMVALIDATIONHOOK β€” if set, uses the %{hook}% command to validate an opam repository update.
  • OPAMVERBOSE β€” see the option --verbose.
  • OPAMVERBOSEON β€” see the option --verbose-on.
  • OPAMVERSIONLAGPOWER β€” do not use. πŸ’€
  • OPAMWITHDEVSETUP β€” see the install option --with-dev-setup.
  • OPAMWITHDOC β€” see the install option --with-doc.
  • OPAMWITHTEST β€” see the install option --with-test.
  • OPAMWORKINGDIR β€” see the option --working-dir.
  • OPAMYES β€” see the options --yes and --confirm-level. OPAMYES has priority over OPAMNO and is ignored if OPAMCONFIRMLEVEL is set.
  • OPAMVAR_var β€” overrides the contents of the variable var when substituting %{var}% strings in opam files.
  • OPAMVAR_package_var β€” overrides the contents of the variable package:var when substituting %{package:var}% strings in opam files.

✨ CLI VERSION ✨

okay so this one is important and you're gonna wanna hear me out. πŸ‘‘

All scripts and programmatic invocations of opam should use --cli in order to ensure that they work seamlessly with future versions of the opam client. And it's not just for scripts β€” blog posts or other documentation can benefit too, because it prevents information from becoming stale.

Although opam only supports roots (~/.opam/) for the current version, it does provide backwards compatibility for its command-line interface.

Since CLI version support was only added in opam 2.1, use OPAMCLI to select 2.0 support (as opam 2.0 will just ignore it), and --cli=2.1 for 2.1 (or later) versions β€” because an environment variable controlling the parsing of syntax is brittle, fr fr. To this end, opam displays a warning if OPAMCLI specifies a valid version other than 2.0, and also if --cli=2.0 is specified.

The command-line version is selected by using the --cli option or the OPAMCLI environment variable. --cli may be specified morethan once, where the last instance takes precedence. OPAMCLI is only inspected if --cli is not given. πŸ’…


πŸšͺ EXIT STATUS (a.k.a. "what did that number MEAN")

Okay bestie, plot twist incoming: the exec command is the ✨rebel✨ that plays by its own rules. It does not follow the list below. exec returns 127 if the command wasn't found or couldn't be executed at all, and otherwise it returns the command's own exit value. That's it, that's the lore. πŸ’…

For literally everything else, here's the codebook:

  • 0 β€” Success, or true for boolean queries. The good ending. πŸŽ€
  • 1 β€” False. This pops up when a boolean return value is what's expected, e.g. when you run with --check, or for queries like opam lint. Lowkey a "no" rather than a "something broke".
  • 2 β€” Bad command-line arguments, or command-line arguments pointing at an invalid context, like a file that doesn't follow the expected format. Bestie, check your flags. 😭
  • 5 β€” Not found. You asked for something β€” a package, a version, a repository, etc. β€” that literally could not be found. It's giving missing.
  • 10 β€” Aborted. The operation needed you to confirm something and you didn't give the confirmation. Consent matters, even in package managers. 🫢
  • 15 β€” Could not acquire the locks required for the operation. Somebody else is holding the door. πŸ”’
  • 20 β€” There is no solution to the user request. This can happen if you ask to install two incompatible packages, for example. The math said no.
  • 30 β€” Error in package definition, or other metadata files. And heads up: using --strict raises this error more often. πŸ‘€
  • 31 β€” Package script error. Some package operations were unsuccessful. This may be an error in the packages or an incompatibility with your system. And note: this can be a partial error β€” so part of it might have worked, which, rude.
  • 40 β€” Sync error. Could not fetch some remotes from the network. This can be a partial error too. The internet is being a flop again. 🌐
  • 50 β€” Configuration error. Opam or your system configuration doesn't allow the operation and needs fixing. Not a bug, a chore.
  • 60 β€” Solver failure. The solver failed to return a sound answer. Could be a broken external solver, or an error in the solver configuration. The solver just handed in blank paper. πŸ’€
  • 99 β€” Internal error. Something went wrong, likely due to a bug in opam itself. Not your fault, babes. Report it.
  • 130 β€” User interrupt. SIGINT was received, generally because the user pressed Ctrl+C. Yeah, that was you. No shame.

And then, for the commands that specifically document their own bit of the spectrum:

  • 0 β€” on success.
  • 123 β€” on indiscriminate errors reported on standard error.
  • 124 β€” on command line parsing errors.
  • 125 β€” on unexpected internal errors (bugs).

πŸ“š FURTHER DOCUMENTATION

Go read more, it's cute over there: https://opam.ocaml.org/doc.


πŸ‘‘ AUTHORS (the icons who built this)

  • David Allsopp <david@tarides.com>
  • Vincent Bernardoff <vb@luminar.eu.org>
  • Raja Boujbel <raja.boujbel@ocamlpro.com>
  • Kate Deplaix <kit-ty-kate@exn.st>
  • Roberto Di Cosmo <roberto@dicosmo.org>
  • Thomas Gazagnaire <thomas@gazagnaire.org>
  • Louis Gesbert <louis.gesbert@ocamlpro.com>
  • Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr>
  • Anil Madhavapeddy <anil@recoil.org>
  • Guillem Rieu <guillem.rieu@ocamlpro.com>
  • Ralf Treinen <ralf.treinen@pps.jussieu.fr>
  • Frederic Tuong <tuong@users.gforge.inria.fr>

Absolute legends, every single one. ✨


πŸ”— SEE ALSO

  • opam(1) β€” go read the main one too, it's the moment.

πŸ› BUGS

Check bug reports at https://github.com/ocaml/opam/issues. If you found one, tell them! They wanna know! 🫢


And that's a wrap, bestie!! πŸ’– This was the OPAM-OPTION(1) manual page from Opam 2.6.1 β€” go forth, run your commands, and may all your exit statuses be 0. πŸŒˆπŸ¦‹βœ¨

πŸ“¦ where this page comes from