OPAM-INSTALL(1)

okay so you found the opam-install page, it lives in the Opam Manual (section 1, she's a classic πŸ’…), and honestly? bestie, this is the one that does the thing. The installing thing. Let's get into it.


✨ NAME ✨

opam-install β€” install a list of packages. That's it. That's the whole job. πŸŽ€


🌸 SYNOPSIS 🌸

opam install [OPTION]… [PACKAGES]…

πŸ¦‹ DESCRIPTION πŸ¦‹

So this command installs one or more packages inside the currently selected switch (peep opam switch if you don't know which one that is, iykyk). And once they're in? The whole ecosystem opens up: you can yeet packages back out with opam remove, glow them up with opam upgrade, and see the full roster with opam list. Also check out opam pin β€” that's the one for managing package versions, rerouting existing packages, or adding packages that literally are not defined in the repositories. So versatile. Main character behaviour fr fr. ✨

All required dependencies of the packages you picked get installed first, obviously, because we're not monsters. Any already-installed packages that have dependencies (or optional dependencies) pointing at the changed packages will get recompiled β€” sorry babes, that's just the cost of doing business. And ngl, the proposed solution might also imply <italics>removing</italics> incompatible or conflicting packages. The solver does not negotiate. πŸ’€

Oh and here's a cute plot twist: if you hand it paths instead of package names, it assumes those paths point to either project source directories containing one or more package definitions (opam files), or directly to opam files themselves. Then the corresponding packages get pinned to their local directory and installed β€” unless --deps-only was specified. Little exception, big impact. πŸ™ˆ


🌈 ARGUMENTS 🌈

  • PACKAGES β€” a list of package names, with an optional version or constraint, like pkg, pkg.1.0 or pkg>=0.5 ; or files or directory names containing package description, with explicit directory (e.g. ./foo.opam or .)

πŸ’… OPTIONS πŸ’…

  • --assume-built β€” for use on locally-pinned packages: it assumes they've already been correctly built and only runs their installation instructions, straight from their source directory. This skips the build instructions entirely and is lowkey so useful when you're installing packages you're actively working on. Implies --inplace-build. And no, no locally-pinned packages will be skipped. Everyone's coming to the party. 🫢
  • --check β€” exits with 0 if all the dependencies of PACKAGES are already installed. If they're not, it prints the names of the missing dependencies to stdout and exits with 1. A vibe check, but for deps. πŸ‘‘
  • --depext-only β€” resolves the package installation normally, but only installs the required system dependencies, without touching the opam switch state or installing any opam packages. Minimal footprint, maximal manners.
  • --deps-only β€” install all its dependencies, but don't actually install the package. Snack on the sides, skip the main course. πŸ“
  • --destdir=DIR β€” copies the files installed by the given package within the current opam switch below the prefix DIR, respecting their hierarchy, after installation. ⚠️ Caution: calling this can overwrite files, but it will never remove files, even if they were installed by a previous use of --destdir, e.g. on a previous version of the same package. See opam remove --destdir to revert. Not me warning you twice, it's giving consequences. 😭
  • --download-only β€” fetches the sources of the packages, but doesn't build or install anything. Window shopping, but make it package management. πŸ›οΈ
  • --formula=FORMULA (absent=[]) β€” experimental! Specify a dependency formula to be verified by the solution, in addition to the switch invariant. The format is the same as for expressing dependencies in package definition files, e.g. '"foo" {>= "1.1"}'. It's giving scientist energy πŸ§ͺ
  • --ignore-conflicts β€” used with --deps-only, ignores conflicts of given package. Peace was never an option, or whatever.
  • --recursive β€” allows recursive lookups of *.opam files. Cf. --subpath also. πŸŒ€
  • --restore β€” attempts to restore packages that were marked for installation but have been removed due to errors. The comeback arc we deserve. ⭐
  • --set-root β€” marks given packages as installed roots. This is the default for newly manually-installed packages. So like, the usual, but now it's officially a choice. πŸ’–
  • --subpath=PATH β€” *.opam files are retrieved from the given sub directory instead of top directory. Sources are then taken from the targeted sub directory; internally only this subdirectory is copied/fetched. It can be combined with --recursive to have a recursive lookup on the subpath. Nested. Layered. Iconic. 🌸
  • --unset-root β€” marks given packages as "installed automatically". Demotes them from root status, respectfully. πŸ’œ

πŸ”₯ PACKAGE BUILD OPTIONS πŸ”₯

  • --assume-depexts β€” skips the installation step for any missing system packages and attempts to proceed with compilation of the opam packages anyway. If the installation succeeds, opam won't prompt you about these system packages ever again. Only meaningful if external dependency handling is enabled. Bold of you, but okay πŸ’…
  • -b, --keep-build-dir β€” keeps the build directories after compiling packages. This is equivalent to setting $OPAMKEEPBUILDDIR to "true". Hoarder energy, but for builds.
  • --build-doc β€” removed in 2.1, use --with-doc instead. She's retired bestie, let her rest πŸͺ¦
  • --build-test β€” removed in 2.1, use --with-test instead. Same vibe, same retirement party.
  • -d, --with-doc β€” builds the package documentation. This only affects packages listed on the command-line. This is equivalent to setting $OPAMWITHDOC (or the deprecated $OPAMBUILDDOC) to "true". Documentation girlies rise up πŸ“šβœ¨
  • --dry-run β€” simulates the command, but doesn't actually perform any changes. This also can be set with environment variable $OPAMDEBUG. Manifesting the install without committing to it πŸ™ˆ
  • --fake β€” this option registers the actions into the opam database, <italics>without actually performing them</italics>.
🚨 WARNING: this option is dangerous and likely to break your opam environment. You probably want --dry-run. You've been warned.

Like, genuinely. It said what it said. πŸ’€

  • --ignore-available-on[=PACKAGES] (default=) β€” forces opam to mark the listed packages as available. This can be used to test compatibility, but expect builds to break when using this. Note that version constraints of the packages' dependencies are unaffected. Chaos testing, and I respect it πŸ”₯
  • --ignore-constraints-on[=PACKAGES] (default=) β€” forces opam to ignore version constraints on all dependencies to the listed packages. This can be used to test compatibility, but expect builds to break when using this. Note that availability of the packages as well as version constraints on optional dependencies and conflicts are unaffected. This is equivalent to setting $OPAMIGNORECONSTRAINTS. Freebirds only. πŸ¦‹
  • --inplace-build β€” when compiling a package which has its source bound to a local directory, process the build and install actions directly in that directory, rather than in a clean copy handled by opam. This only affects packages that are explicitly listed on the command-line. This is equivalent to setting $OPAMINPLACEBUILD to "true". Build in place, like a boss πŸ’…
  • -j JOBS, --jobs=JOBS β€” set the maximal number of concurrent jobs to use. The default value is calculated from the number of cores. You can also set it using the $OPAMJOBS environment variable. Parallelism, periodt. ⚑
  • --lock-suffix=SUFFIX (absent=locked) β€” set locked files suffix to SUFFIX. Customise the little name-tag. πŸŽ€
  • --locked β€” in commands that use opam files found from pinned sources, if a variant of the file with an added .locked extension is found (e.g. foo.opam.locked besides foo.opam), that will be used instead. This is typically useful to offer a more specific set of dependencies and reproduce similar build contexts, hence the name. The lock option can be used to generate such files, based on the versions of the dependencies currently installed on the host. This is equivalent to setting the $OPAMLOCKED environment variable. Note that this option doesn't generally affect already pinned packages. Locked in, literally πŸ”’
  • -m MAKE, --make=MAKE β€” removed in 2.1, use opam config set[-global] make MAKE instead. Gone but not forgotten πŸͺ¦
  • --no-checksums β€” do not verify the checksum of downloaded archives. This is equivalent to setting $OPAMNOCHECKSUMS to "true". Living dangerously, no cap.
  • --no-depexts β€” temporarily disables handling of external dependencies. This can be used if a package is not available on your system package manager, but you installed the required dependency by hand. Implies --assume-depexts, and stores the exceptions upon success as well. DIY queen behaviour πŸ‘‘
  • --require-checksums β€” reject the installation of packages that don't provide a checksum forthe upstream archives. This is equivalent to setting $OPAMREQUIRECHECKSUMS to "true". Strict. Trust issues. Valid. 🫢
  • --reuse-build-dir β€” reuse existing build directories (kept by using --keep-build-dir), instead of compiling from a fresh clone of the source. This can be faster, but also lead to failures if the build systems of the packages don't handle upgrades of dependencies well. This is equivalent to setting $OPAMREUSEBUILDDIR to "true". Speedrun strat, with a risk warning attached ⚠️
  • --show-actions β€” call the solver and display the actions. Don't perform any changes. This is equivalent to setting $OPAMSHOW. Show me the receipts, no touching πŸ“‹
  • --skip-updates β€” when running an install, upgrade or reinstall on source-pinned packages, they are normally updated from their origin first. This flag disables that behaviour and will keep them to their version in cache. This is equivalent to setting $OPAMSKIPUPDATE. Staying in your lane, keeping your cache. πŸ’Ύ
  • -t, --with-test β€” build and run the package unit-tests. This only affects packages listed on the command-line. This is equivalent to setting $OPAMWITHTEST (or the deprecated $OPAMBUILDTEST) to "true". Test girlies, we love you πŸ§ͺπŸ’–
  • --unlock-base β€” removed in 2.1, use --update-invariant instead. Another one for the archive.
  • --update-invariant β€” allow changes to the packages set as switch base (typically, the main compiler). Use with caution. This is equivalent to setting the $OPAMUNLOCKBASE environment variable. Big red button energy 🚨
  • --verbose-on=PACKAGES β€” be more verbose on specific packages. This is equivalent to setting $OPAMVERBOSE. Spill the tea, in detail 🌸
  • --with-dev-setup β€” include development tools only dependencies. Dev tools besties get an invite too πŸ› οΈβœ¨

and that's the first chunk bestie, keep scrolling, we're not done yet πŸ’œ

πŸ’… COMMON OPTIONS πŸ’…

okay bestie, these ones are the OGs β€” they work on every single command, no cap. ✨

  • --best-effort β€” pls don't crash out if not every package you asked for can actually be installed. this says: just try to install as many as you can and vibe πŸ’–. heads up though β€” not every external solver supports this (recent versions of aspcud or mccs should, but iykyk). it's literally the same as setting the $OPAMBESTEFFORT environment variable.
  • --cli=MAJOR.MINOR (absent=2.6) β€” use the command-line interface syntax and semantics from version MAJOR.MINOR. this is for the girlies doing persistent opam stuff β€” scripts, blog posts, that kind of permanent slay. any version of opam in the same MAJOR series will behave like the MINOR release you specified. tiny caveat: this flag wasn't a thing back in opam 2.0, so if you wanna select the 2.0 CLI you have to set the OPAMCLI environment variable to 2.0 instead of using this parameter. periodt.
  • --color=WHEN β€” colorize the output obvi πŸŽ€. WHEN has to be one of always, never or auto.
  • --confirm-level=LEVEL β€” set the confirmation level bestie. LEVEL must be one of ask, no, yes or unsafe-yes. you can pass this more than once. if --yes or --no are also given, whichever --confirm-level came last wins. this is equivalent to setting $OPAMCONFIRMLEVEL (yes the manpage has a stray backtick there, i'm keeping it fr πŸ™ˆ).
  • --criteria=CRITERIA β€” tell opam your ✨preferences✨ for dependency solving, just for this one run. this overrides $OPAMCRITERIA, $OPAMFIXUPCRITERIA and $OPAMUPGRADECRITERIA. for the deets on the supported language and which external solvers exist, peek at http://opam.ocaml.org/doc/External_solvers.html. and there's a whole general guide to using solver preferences at http://www.dicosmo.org/Articles/usercriteria.pdf.
  • --cudf=FILENAME β€” debug option πŸ›: saves the CUDF requests sent to the solver into FILENAME-<n>.cudf, where <n> is the n-th call to the solver during the opam run.
  • --debug β€” print debug messages to stderr. equivalent to setting $OPAMDEBUG to "true".
  • --debug-level=LEVEL β€” same energy as --debug, except you get to pick the debug level yourself (--debug just sets it to 1). equivalent to setting $OPAMDEBUG to a positive integer.
  • --git-version β€” print the git version of opam if it's set (aka you're living that development-version life 😌) and then exit.
  • --help[=FMT] (default=auto) β€” show this help in format FMT. FMT must be one of auto, pager, groff or plain. with auto, the format ends up being pager or plain whenever the TERM env var is dumb or just straight-up undefined.
  • --ignore-pin-depends β€” ignore the extra pins that packages require when they get pinned β€” whether that's manually through opam pin or through opam install DIR. equivalent to setting IGNOREPINDEPENDS=true.
  • --json=FILENAME β€” save the results of the opam run into a computer-readable file πŸ€–. if the filename contains the character %, it gets swapped out for an index that won't overwrite an existing file. similar to setting the $OPAMJSON variable.
  • --no β€” answer no to literally all of opam's yes/no questions, no prompting, no hesitation πŸ’€. see also --confirm-level. equivalent to setting $OPAMNO to "true".
  • --no-aspcud β€” removed in 2.1. rest in peace queen πŸͺ¦.
  • --no-auto-upgrade β€” when opam configures or updates a repository written for an earlier opam version (1.2), it internally converts it to the current format. this turns that behaviour off. important note bestie: repositories should declare their format version in a 'repo' file at their root, otherwise they'll be assumed to be in the older format. and honestly? it's preferable in any case to upgrade the repositories manually with opam admin upgrade [--mirror URL] whenever you can.
  • --no-self-upgrade β€” by default opam will replace itself with a newer binary found at OPAMROOT/opam if one's there (main character energy, honestly). this disables that behaviour.
  • -q, --quiet β€” disables --verbose.
  • --root=ROOT β€” use ROOT as the current root path. equivalent to setting $OPAMROOT to ROOT.
  • --safe, --readonly β€” make absolutely sure nothing gets automatically updated or rewritten πŸ”’. super useful when you're calling from completion scripts for example. it will fail whenever such an operation is actually needed; it also skips waiting for locks, skips interactive questions, and overrides the $OPAMDEBUG variable. equivalent to setting the $OPAMSAFE environment variable.
  • --solver=CMD β€” pick the CUDF solver used for resolving package installation problems. CMD is either a predefined solver β€” and 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}%. equivalent to setting $OPAMEXTERNALSOLVER.
  • --strict β€” fail whenever an error turns up in a package definition or a configuration file. the default is to just keep going silently if possible 🀫.
  • --switch=SWITCH β€” use SWITCH as the current compiler switch. equivalent to setting $OPAMSWITCH to SWITCH.
  • --use-internal-solver β€” disable any external solver and use the built-in one instead (heads up: this requires that opam was compiled with a built-in solver). equivalent to setting $OPAMNOASPCUD or $OPAMUSEINTERNALSOLVER.
  • -v, --verbose β€” be more verbose πŸ—£οΈ. one -v shows all package commands; repeat it to also display commands called internally (think tar, curl, patch etc.). repeating it n times is equivalent to setting $OPAMVERBOSE to "n".
  • --version β€” show version information. iconic, short, does exactly what it says πŸ‘‘.
  • -w, --working-dir β€” whenever opam updates packages that are bound to a local, version-controlled directory, this updates them to the current working state of their source instead of the last committed state, or the ref they're pointing to. ⚠️ heads up: since the source directory gets copied as-is, if it isn't clean it may result in an 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 of opam's yes/no questions without prompting. so efficient, so slay ✨. see also --confirm-level. equivalent to setting $OPAMYES to "true".


🌸 ENVIRONMENT 🌸

okay so bestie, opam is lowkey reading your environment the whole time πŸ‘€ it makes use of the environment variables listed right here, and you should absolutely know about them because they're your secret little levers 🎚️✨

one thing first: the boolean ones? they should be set to "0", "no", "false" or the empty string to disable them, and "1", "yes" or "true" to enable them. no cap, that's the whole rule 🫢


THE FULL LIST πŸ’–

  • OPAMALLPARENS β€” surrounds all filters with parenthesis. like, every single one, all wrapped up πŸŽ€
  • OPAMASSUMEDEPEXTS β€” see option --assume-depexts.
  • OPAMAUTOANSWER β€” internal use only. not for you, bestie πŸ™ˆ
  • OPAMAUTOREMOVE β€” see the 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 it's expected to maximise the opam-query property in the solution πŸ’…
  • OPAMBUILDDOC β€” Removed in 2.1. she's gone, periodt πŸ’€
  • OPAMBUILDTEST β€” Removed in 2.1. also gone πŸͺ¦
  • OPAMCLI β€” see option --cli.
  • OPAMCOLOR β€” when set to always or never, it sets a default value for the --color option 🌈
  • OPAMCONFIRMLEVEL β€” see option --confirm-level. heads up: OPAMCONFIRMLEVEL has priority over OPAMYES and OPAMNO πŸ‘‘
  • OPAMCRITERIA β€” specifies user preferences for dependency solving. the default value depends on the solver version, so 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, it 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. go big or go home πŸ•΅οΈ
  • OPAMDOWNLOADJOBS β€” sets the maximum number of simultaneous downloads. parallel queen behaviour ✨
  • 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 option --dry-run.
  • OPAMEDITOR β€” sets the editor to use for opam file editing, and it overrides $EDITOR and $VISUAL. main character energy only 🧚
  • OPAMERRLOGLEN β€” sets the number of log lines printed when a sub-process fails. 0 to print all of them.
  • OPAMEXTERNALSOLVER β€” see option --solver.
  • OPAMFAKE β€” see option --fake.
  • 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. this 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. multitasking icon πŸ’…
  • OPAMJSON β€” log json output to the given file (use the 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 β€” a combination of --locked and --lock-suffix options.
  • OPAMLOGS β€” logdir sets the log directory, and the default is a temporary directory in /tmp.
  • OPAMMAKECMD β€” set the system make command to use.
  • OPAMMERGEOUT β€” merge process outputs, with stderr on stdout.
  • OPAMNO β€” answers no to any question asked, see options --no and --confirm-level. OPAMNO is ignored if either OPAMCONFIRMLEVEL or OPAMYES is set πŸ™…
  • OPAMNOAGGREGATE β€” with opam admin check, don't aggregate packages.
  • OPAMNOASPCUD β€” Deprecated. hard pass, bestie.
  • 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. nothing to see here πŸ™ˆ
  • 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 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. ok that's actually so smart 🧠✨
  • OPAMREQUIRECHECKSUMS β€” enables option --require-checksums when available (e.g. for opam install).
  • OPAMRETRIES β€” sets the number of tries before failing downloads. manifesting a successful download πŸ”
  • 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. you do you, bestie πŸ‘‘
  • OPAMSAFE β€” see option --safe.
  • OPAMSHOW β€” see option --show.
  • OPAMSKIPUPDATE β€” see 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 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. rest in peace πŸͺ¦
  • OPAMSTATUSLINE β€” display a dynamic status line showing what's currently going on on the terminal. (one of always, never or auto)
  • OPAMSTRICT β€” fail on inconsistencies (file reading, switch import, etc.). no sloppy vibes allowed 🚫
  • 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. it overrides OPAMCRITERIA in upgrades if both are set. see also option --criteria.
  • OPAMUSEINTERNALSOLVER β€” see option --use-internal-solver.
  • OPAMUSEOPENSSL β€” Removed in 2.2. bye babe πŸ’€
  • OPAMUTF8 β€” use UTF8 characters in output (one of always, never or auto). by default it's auto, which is determined from the locale πŸ¦‹
  • OPAMUTF8MSGS β€” use extended UTF8 characters (camels πŸͺ) in opam messages. it 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 option --verbose.
  • OPAMVERBOSEON β€” see option --verbose-on.
  • OPAMVERSIONLAGPOWER β€” do not use. literally just don't πŸ™ˆ
  • 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. yes queen, say yes to everything ✨
  • 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 this one is actually important for the girlies writing scripts, so 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. and not just scripts β€” blog posts or other documentation can benefit too, because it prevents information from becoming stale. the way that future-proofing 🫢

although opam only supports roots (~/.opam/) for the current version, it does provide backwards compatibility for its command-line interface. slay πŸ’…

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. so yeah, you'll get called out ⚠️

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.

πŸ’€ EXIT STATUS

ok so this is the part where opam tells you how it's feeling, in numbers. Every code is a whole mood and honestly you're gonna want to know these by heart, bestie.

⚠️ one exception first, don't skip this: the exec command breaks the pattern. It returns 127 if the command wasn't found or couldn't be executed, and otherwise it just hands you back the command's own exit value. That's it, that's the whole exception. ✨

Here's the lineup:

  • 0 β€” Success, or true for boolean queries. everything's giving immaculate vibes πŸ’–
  • 1 β€” False. Comes back when a boolean return value is expected, like when you run with --check, or for queries such as opam lint.
  • 2 β€” Bad command-line arguments, or command-line args pointing at an invalid context (e.g. a file that doesn't follow the expected format). not the vibe πŸ™ˆ
  • 5 β€” Not found. You asked for something (package, version, repository, etc.) that couldn't be found. it's giving "who is she"
  • 10 β€” Aborted. The operation needed confirmation, and you didn't give it.
  • 15 β€” Could not acquire the locks required for the operation. πŸ”’
  • 20 β€” There is no solution to the user request. This can happen if you ask to install two incompatible packages, for example. lowkey heartbreaking 😭
  • 30 β€” Error in package definition, or other metadata files. Using --strict raises this error more often. she's picky, and honestly? valid.
  • 31 β€” Package script error. Some package operations were unsuccessful. This may be an error in the packages or an incompatibility with your system. This can be a partial error.
  • 40 β€” Sync error. Could not fetch some remotes from the network. This can be a partial error too.
  • 50 β€” Configuration error. Opam or system configuration doesn't allow the operation, and it needs fixing.
  • 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.
  • 99 β€” Internal error. Something went wrong, and it's likely a bug in opam itself. πŸ› main character bug energy, but like, the bad kind.
  • 130 β€” User interrupt. SIGINT was received, generally because you pressed Ctrl+C. not me panicking and mashing keys πŸ’…

and then the page also drops this little squad of numbers, right at the end, exactly like this:

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

periodt. memorize them, screenshot them, put them in your notes app. future you says thank you. πŸ“βœ¨


πŸ“š FURTHER DOCUMENTATION

the lore continues at https://opam.ocaml.org/doc. go read, bestie, it's giving homework but make it cute. πŸ¦‹


πŸ‘‘ AUTHORS

these are the literal icons who built this. absolute legends, every single one:

  • 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

no cap, round of applause 🫢🌸


🌈 SEE ALSO


πŸ› BUGS

found something cursed? check the bug reports at https://github.com/ocaml/opam/issues. spilling the tea responsibly is self care. πŸ’œ


ok that's the WHOLE page bestie, you made it to the end, we're both so proud of you πŸŽ€βœ¨ one last thing: the footer of this page says Opam 2.6.1 on one side and OPAM-INSTALL(1) on the other, and the date slot is just sitting there empty like πŸ‘€ β€” so if you're ever citing this, that's the version you're reading, and that's the section name. now go run opam install something iconic and text me how it goes πŸ’…πŸ”₯πŸ’–

πŸ“¦ where this page comes from