OPAM-CONFIG(1)

πŸ’– OPAM-CONFIG πŸ’–

okay bestie, welcome to the opam-config page, straight out of the Opam Manual. this is part 1 of 3, so buckle up, we're not done yet ✨


🌸 NAME 🌸

opam-config β€” Display configuration options for packages.

i know. riveting. but it's actually useful, i promise 🫢


πŸŽ€ SYNOPSIS πŸŽ€

opam config [OPTION]… [COMMAND] [ARG]…

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, this command goes digging through your opam state and spills the tea on how to use your installed libraries, how to update your PATH, and how to substitute variables that opam packages use. pretty iconic of it honestly πŸ’…

but here's the vibe check: apart from opam config env, most of these commands are used by opam internally, and are of limited interest for the casual user. so like. don't stress if you never touch them. iykyk 😌


πŸ‘‘ COMMANDS πŸ‘‘

  • env β€” Returns the bindings for the environment variables set in the current switch, e.g. PATH, in a format intended to be evaluated by a shell. With -v, add comments documenting the reason or package of origin for each binding. This is most usefully used as eval $(opam config env) to have further shell commands be evaluated in the proper opam context. Can also be accessed through opam env. ✨ this one is the main character, no cap.
  • revert-env β€” Reverts environment changes made by opam, e.g. eval $(opam config revert-env) undoes what eval $(opam config env) did, as much as possible. it's giving "undo button but make it shell" 😭
  • list [PACKAGE]... β€” Without argument, prints a documented list of all available variables. With PACKAGE, lists all the variables available for these packages.
  • expand STRING β€” Expand variable interpolations in the given string
  • subst FILE... β€” Substitute variables in the given files. The strings %{var}% are replaced by the value of variable var (see var).
  • report β€” Prints a summary of your setup, useful for bug-reports. πŸ›
  • cudf-universe [FILE] β€” Outputs the current available package universe in CUDF format.
  • pef-universe [FILE] β€” Outputs the current package universe in PEF format.
  • exec [--] COMMAND [ARG]... β€” Removed in 2.1, use opam exec instead.
  • set VAR VALUE β€” Removed in 2.1, use opam var instead.
  • unset VAR β€” Removed in 2.1, use opam var instead.
  • set-global VAR VALUE β€” Removed in 2.1, use opam var instead.
  • unset-global VAR β€” Removed in 2.1, use opam var instead.
  • var VAR β€” Removed in 2.1, use opam var instead.
⚠️ bestie. the whole back half of this list got yeeted in 2.1. if you're out here typing opam config set, that's a ghost πŸ‘». use opam var / opam exec and move on. periodt.

πŸ’… OPTIONS πŸ’…

  • --inplace-path β€” When updating the PATH variable, replace any pre-existing opam path in-place rather than putting the new path in front. This means programs installed in opam that were shadowed will remain so after opam env. lowkey a glow-up for your PATH β€” it edits in place instead of jumping the queue πŸŽ€
  • --set-root β€” With the env and exec subcommands, also sets the OPAMROOT variable, making sure further calls to opam will use the same root.
  • --set-switch β€” With the env and exec subcommands, also sets the OPAMSWITCH variable, making sure further calls to opam will use the same switch as this one.
  • --sexp β€” Print environment as an s-expression rather than in shell format
  • --shell=SHELL β€” Sets the configuration mode for opam environment appropriate for SHELL. One of bash, sh, csh, zsh, fish, pwsh, cmd or powershell. Guessed from the parent processes and the $SHELL variable by default.

🌈 COMMON OPTIONS 🌈

these ones are common to all commands, so like... collective slay. they show up everywhere 🫢

  • --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. it's giving "we tried our best" energy πŸ’ͺ
  • --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. bestie we are NOT living in a world without color ✨
  • --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.
🚨 unsafe-yes is literally right there in the name. it means yes to everything, no questions, no takesies backsies. be so fr before you type that.
  • --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. hi yes this is the one you're using right now, hello πŸ‘‹
  • --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.
  • --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. shhhhh 🀫
  • --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. it's giving "look but don't touch" 🧚
  • --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. not me flipping this on and getting absolutely cooked by my own config files πŸ’€
  • --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". the way that stacking -v just keeps revealing more... shiny ✨
  • --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.
🌸 heads up bestie: if your working dir is messy, that messiness gets copied as-is and can cause a build failure. clean your room before you invite opam in πŸŽ€
  • -y, --yes β€” Answer yes to all opam yes/no questions without prompting. See also --confirm-level. This is equivalent to setting $OPAMYES to "true".

🌸 that's part 1! keep scrolling, there's more πŸ‘‘

ok bestie, this next bit is a BIG one, so hydrate first πŸ“


🌈 ENVIRONMENT 🌈

so opam reads a whole bunch of environment variables, and they're basically little vibes you set in your shell to change how opam behaves. πŸ’…

quick rule for the boolean ones (the yes/no girlies): set them to "0", "no", "false" or the empty string to disable, and "1", "yes" or "true" to enable. periodt. ✨

  • OPAMALLPARENS β€” surround all filters with parenthesis. yes, all of them. 🫢
  • OPAMASSUMEDEPEXTS β€” see option --assume-depexts.
  • OPAMAUTOANSWER β€” internal use only. nothing to see here bestie πŸ™ˆ
  • OPAMAUTOREMOVE β€” see remove option --auto-remove.
  • OPAMBESTEFFORT β€” see option --best-effort.
  • OPAMBESTEFFORTPREFIXCRITERIA β€” sets the string that must be prepended to the criteria when the --best-effort option is set, and is expected to maximise the opam-query property in the solution.
  • OPAMBUILDDOC β€” Removed in 2.1. she's gone, don't look for her πŸ’€
  • OPAMBUILDTEST β€” Removed in 2.1. also gone.
  • OPAMCLI β€” see option --cli.
  • OPAMCOLOR β€” when set to always or never, sets a default value for the --color option.
  • OPAMCONFIRMLEVEL β€” see option --confirm-level. OPAMCONFIRMLEVEL has priority over OPAMYES and OPAMNO. she's the main character here πŸ‘‘
  • 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 option --criteria.
  • 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 options --debug and --debug-level.
  • 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 explicitly named on the command-line.
  • OPAMDRYRUN β€” see option --dry-run.
  • OPAMEDITOR β€” sets the editor to use for opam file editing, overrides $EDITOR and $VISUAL.
  • OPAMERRLOGLEN β€” sets the number of log lines printed when a sub-process fails. 0 to print all. all of them. every last one. 😭
  • OPAMEXTERNALSOLVER β€” see option --solver.
  • OPAMFAKE β€” see option --fake.
  • OPAMFETCH β€” specifies how to download files: either wget, curl or a custom command where variables %{url}%, %{out}%, %{retry}%, %{compress}% and %{checksum}% will be replaced. Overrides the download-command value from the main config file.
  • OPAMFIXUPCRITERIA β€” same as OPAMUPGRADECRITERIA, but specific to fixup and reinstall.
  • OPAMIGNOREAVAILABLE β€” see install option --ignore-available-on.
  • OPAMIGNORECONSTRAINTS β€” see install option --ignore-constraints-on.
  • OPAMIGNOREPINDEPENDS β€” see option --ignore-pin-depends.
  • OPAMINPLACEBUILD β€” see option --inplace-build.
  • OPAMJOBS β€” sets the maximum number of parallel workers to run.
  • OPAMJSON β€” log json output to the given file (use character % to index the files).
  • OPAMKEEPBUILDDIR β€” see 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 --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 options --no and --confirm-level. OPAMNO is ignored if either OPAMCONFIRMLEVEL or OPAMYES is set. she's got no seniority, sorry πŸ˜”
  • 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 option --no-checksums when available.
  • OPAMNODEPEXTS β€” disables system dependencies handling, see option --no-depexts.
  • OPAMNOENVNOTICE β€” Internal.
  • OPAMNOSELFUPGRADE β€” see 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 might help debugging solver issue.
  • 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 operation are done in-memory, no I/O for scanning the repository.
  • OPAMREQUIRECHECKSUMS β€” Enables option --require-checksums when available (e.g. for opam install).
  • OPAMRETRIES β€” sets the number of tries before failing downloads.
  • OPAMREUSEBUILDDIR β€” see option --reuse-build-dir.
  • OPAMROOT β€” see option --root. This is automatically set by opam env --root=DIR --set-root.
  • OPAMROOTISOK β€” don't complain when running as root.
  • OPAMSAFE β€” see option --safe.
  • OPAMSHOW β€” see option --show.
  • OPAMSKIPUPDATE β€” see option --skip-updates.
  • OPAMSKIPVERSIONCHECKS β€” bypasses some version checks. Unsafe, for compatibility testing only. ⚠️ read that again bestie, it literally says unsafe.
  • 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 will continue 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. rip πŸͺ¦
  • 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 option --switch. Automatically set by opam env --switch=SWITCH --set-switch.
  • OPAMUNLOCKBASE β€” see 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 option --criteria.
  • OPAMUSEINTERNALSOLVER β€” see 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. πŸͺ iconic honestly
  • OPAMVALIDATIONHOOK β€” if set, uses the %{hook}% command to validate an opam repository update.
  • OPAMVERBOSE β€” see option --verbose.
  • OPAMVERBOSEON β€” see option --verbose-on
  • OPAMVERSIONLAGPOWER β€” do not use. 🚫 that's it, that's the whole description, don't use it.
  • OPAMWITHDEVSETUP β€” see install option --with-dev-setup.
  • OPAMWITHDOC β€” see install option --with-doc.
  • OPAMWITHTEST β€” see install option `--with-test.
  • OPAMWORKINGDIR β€” see option --working-dir.
  • OPAMYES β€” see 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 πŸ”₯

ok so this part is genuinely important bestie, listen up πŸ“’

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. Additionally, blog posts or other documentation can benefit, as 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, since an environment variable controlling the parsing of syntax is brittle. 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 more than once, where the last instance takes precedence. OPAMCLI is only inspected if --cli is not given.

ngl the last-one-wins thing is giving "the final girl standing gets the crown" energy πŸ‘‘

πŸšͺ EXIT STATUS πŸšͺ

okay so before we get into the numbers, one lil exception to everything below that you need to know: the exec command is a whole different beast. It returns 127 if the command wasn't found or literally could not be executed, and otherwise it just hands you back the command's own exit value. That's it, that's the exec lore. 🫢

Now the actual codes, bestie, in order:

  • 0 β€” Success πŸ’– or true for boolean queries. Living the dream.
  • 1 β€” False. You get this when a boolean return value is expected, like when you're running with --check, or for queries like opam lint. It's not an error, it's just a no. πŸ™ˆ
  • 2 β€” Bad command-line arguments, or command-line arguments pointing at an invalid context (e.g. a file that doesn't follow the expected format). Basically: the vibes you handed opam were illegible.
  • 5 β€” Not found. You asked for something (package, version, repository, etc.) that couldn't be found. It's giving ghosted. πŸ‘»
  • 10 β€” Aborted. The operation needed confirmation and you didn't give it. no confirmation, no service. πŸ’…
  • 15 β€” Could not acquire the locks required for the operation. The locks were giving occupied. πŸ”’
  • 20 β€” There is no solution to the user request. This can happen when you ask to install two incompatible packages, for example. Math said no. 😭
  • 30 β€” Error in package definition, or other metadata files. Also, using --strict raises this error more often. careful with that one πŸŽ€
  • 31 β€” Package script error. Some package operations were unsuccessful. This may be an error in the packages or an incompatibility with your system. Note: this can be a partial error. 🌸
  • 40 β€” Sync error. Could not fetch some remotes from the network. Also note: this can be a partial error. 🌈
  • 50 β€” Configuration error. Opam or system configuration doesn't allow the operation, and needs fixing. Someone has to go in there and fix it, and that someone is you. ✨
  • 60 β€” Solver failure. The solver failed to return a sound answer. It can be due to a broken external solver, or an error in solver configuration. the solver woke up and chose chaos πŸ’€
  • 99 β€” Internal error. Something went wrong, likely due to a bug in opam itself. Not you, babe. It's opam. 😭
  • 130 β€” User interrupt. SIGINT was received, generally because the user pressed Ctrl+C. that was you. you did that. πŸ™ˆ

aaaand then there's the second little cluster, the command-line-toolkit-flavoured ones:

  • 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 πŸ“š

See https://opam.ocaml.org/doc. Go read it, it's giving academic baddie. πŸŽ€


πŸ‘‘ AUTHORS πŸ‘‘

the literal icons who built this, in order, no cap:

  • 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>

slay. every single one. πŸ’œ


πŸ¦‹ SEE ALSO πŸ¦‹

that's the one, bestie, that's the gateway. 🌸


πŸ’€ BUGS πŸ’€

Found a bug? Check bug reports at https://github.com/ocaml/opam/issues. Not me reading issue threads at 2am like they're fanfic. πŸ™ˆ


and that's the whole page, bestie!! you made it to the end of OPAM-CONFIG(1) and honestly? iconic behaviour. πŸ’–

This lil masterpiece lives in Opam 2.6.1, and its date stamp says OPAM-CONFIG(1) down at the bottom like a lil signature. now go forth and opam config responsibly. mwah. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from