OPAM-WHY(1)
๐ opam-why โ the opam manual, but make it make sense ๐
OK so bestie, you opened the manual for opam-why(1) and honestly? This one's a little cutie. It's short, it's sweet, and it's lowkey just an alias doing its best. Let's get into it ๐ซถ
โจ NAME โจ
opam-why โ literally just an alias for tree --rev-deps. That's the whole personality. It's giving "new phone who dis" except the phone is opam tree in a trench coat ๐
๐ธ SYNOPSIS ๐ธ
opam why [--recursive] [--subpath=PATH] [OPTION]โฆ [PACKAGES]โฆ
Like, you pass it some packages, it tells you why they matter to the dependency graph. Iconic behavior, no notes ๐
๐ฆ DESCRIPTION ๐ฆ
So here's the tea: opam why is an alias for opam tree --rev-deps. Same command, different name, zero drama ๐
If you want the actual full details, go read opam tree --help. This page is just the vibe check.
๐ TREE FILTERING OPTIONS ๐
These ones decide which slice of the tree you actually get to see. Very "choose your own adventure" of it โจ
--leads-toโ Shows you only the branches that lead to one of thePACKAGES. So if you're like "okay but WHY does this package exist in my life", this is the one ๐ต๏ธ๐--roots-fromโ Shows only the trees that root from one of thePACKAGES. And yes, this is the default, so if you didn't ask for anything else, this is what you're getting, no cap ๐
๐ TREE BUILDING OPTIONS ๐
Now we're building the actual forest. Unhinged that a CLI has a forest but okay, we love a nature metaphor ๐ณ
--depsโ Draws a dependency forest, starting from the packages that nothing else requires. Basically the top-level girlies. And this is the default ๐--rev-depsโ Draws a reverse-dependency forest, starting from the packages which have no dependencies. The ones holding up nobody but themselves. Main character energy fr fr ๐ฅ
๐ PACKAGE SELECTION OPTIONS ๐
Which packages get invited to the party ๐
--devโ Includes development packages in dependencies. Bring them along, they're fun ๐ซถ--no-switchโ Ignores the active switch and pretends you're installing packages into a completely empty switch, just to draw the forest. Fresh start, blank slate, no baggage โจ--postโ Includes dependencies tagged as post. Not pre, not mid โ post ๐-t,--with-test,--testโ Includes test-only dependencies. Three names, one icon ๐--with-dev-setupโ Includes developer-only dependencies. You know, the ones only you need, bestie ๐ง--with-doc,--docโ Includes doc-only dependencies. For the readers, the learners, the girlies who read the docs ๐๐ธ
โญ OUTPUT FORMAT OPTIONS โญ
--no-constraintโ Hides the version constraints, like(>= 1.0.0). So you get the vibes without the numbers ๐ซ
๐ ARGUMENTS ๐
PACKAGESโ A list of package names, and you can toss in an optional version or constraint, likepkg,pkg.1.0orpkg>=0.5. OR you can hand it files or directory names that contain package descriptions โ but you must be explicit about the directory, like./foo.opamor.๐ No sneaky implicit paths, the command will not be doing that guesswork for you.
๐ฅ OPTIONS ๐ฅ
--recursiveโ Allows recursive lookups of*.opamfiles. Also peep--subpath, they're besties ๐--subpath=PATHโ Grabs the*.opamfiles from the given subdirectory instead of the top directory. Sources get taken from that targeted subdirectory too โ internally, only that subdirectory is copied/fetched. You can pair it with--recursiveto do a recursive lookup on the subpath. Combo move ๐ค
๐ COMMON OPTIONS ๐
These are the options that show up across all the commands. The shared wardrobe, if you will ๐
--best-effortโ Won't fail just because not every requested package can be installed: it'll try to install as many as it can. Heads up though, not all external solvers support this (recent versions ofaspcudormccsshould). It's equivalent to setting the$OPAMBESTEFFORTenvironment variable.--cli=MAJOR.MINOR(absent=2.6) โ Use the command-line interface syntax and semantics ofMAJOR.MINOR. This is meant 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 wasn't available in opam 2.0, so to select the 2.0 CLI, set theOPAMCLIenvironment variable to2.0instead of using this parameter. iykyk ๐--color=WHENโ Colorizes the output. WHEN must be one ofalways,neverorauto. We love a little sparkle โจ--confirm-level=LEVELโ Confirmation level, LEVEL must be one ofask,no,yesorunsafe-yes. Can be specified more than once. If--yesor--noare also given, the value of the last--confirm-levelis taken into account. This is equivalent to setting$OPAMCONFIRMLEVEL. Multiple times! It's giving layers ๐--criteria=CRITERIAโ Specify user preferences for dependency solving for this run. Overrides$OPAMCRITERIA,$OPAMFIXUPCRITERIAand$OPAMUPGRADECRITERIA. For details on the supported language, and the external solvers available, seehttp://opam.ocaml.org/doc/External_solvers.html. A general guide to using solver preferences can be found athttp://www.dicosmo.org/Articles/usercriteria.pdf. Homework assigned, bestie ๐--cudf=FILENAMEโ Debug option: saves the CUDF requests sent to the solver toFILENAME-<n>.cudfwhere<n>is the n-th call to the solver during the opam run. Deep lore ๐--debugโ Prints debug messages to stderr. Equivalent to setting$OPAMDEBUGto"true".--debug-level=LEVELโ Like--debug, but you get to specify the debug level (--debugsets it to1). Equivalent to setting$OPAMDEBUGto a positive integer. Turn that dial up ๐๏ธ--git-versionโ Prints the git version of opam, if it's set (i.e. you're on a development version), and exits. Peek behind the curtain ๐ญ--help[=FMT](default=auto) โ Shows this help in format FMT. FMT must be one ofauto,pager,grofforplain. Withauto, the format ispagerorplainwhenever theTERMenv var isdumbor undefined. You are here ๐--ignore-pin-dependsโ Ignores extra pins required by packages that get pinned, whether that's manually throughopam pinor throughopam install DIR. Equivalent to settingIGNOREPINDEPENDS=true.--json=FILENAMEโ Saves the results of the opam run into a computer-readable file. If the filename contains the character%, it gets replaced by an index that doesn't overwrite an existing file. Similar to setting the$OPAMJSONvariable. Machine-readable slay ๐ค--noโ Answers no to all opam yes/no questions without prompting. See also--confirm-level. Equivalent to setting$OPAMNOto"true". Respectfully declining everything ๐ โ๏ธ--no-aspcudโ Removed in 2.1. She's gone, she's retired, we don't talk about her ๐--no-auto-upgradeโ When configuring or updating a repository that was written for an earlier opam version (1.2), opam internally converts it to the current format. This disables that behavior. Note that repositories should define their format version in a'repo'file at their root, otherwise they'll be assumed to be in the older format. It is, in any case, preferable to upgrade the repositories manually usingopam admin upgrade [--mirror URL]when possible.--no-self-upgradeโ Opam will replace itself with a newer binary found atOPAMROOT/opamif present. This disables that behavior. No auto-glow-up for opam today ๐ซ-q,--quietโ Disables--verbose. Shhh ๐คซ--root=ROOTโ Uses ROOT as the current root path. Equivalent to setting$OPAMROOTto ROOT.--safe,--readonlyโ Makes sure nothing gets automatically updated or rewritten. Handy for calling from completion scripts, for example. It will fail whenever such an operation is needed; it also avoids waiting for locks, skips interactive questions and overrides the$OPAMDEBUGvariable. Equivalent to setting the environment variable$OPAMSAFE. Look but don't touch ๐ซถ--solver=CMDโ Specifies the CUDF solver to use for resolving package installation problems. This is either a predefined solver โ this version of opam supportsbuiltin-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. Pick your fighter โ๏ธ--strictโ Fails whenever an error is found in a package definition or a configuration file. The default is to continue silently if possible. Zero tolerance mode ๐--switch=SWITCHโ Uses SWITCH as the current compiler switch. Equivalent to setting$OPAMSWITCHto SWITCH.--use-internal-solverโ Disables any external solver and uses the built-in one (this requires that opam was compiled with a built-in solver). Equivalent to setting$OPAMNOASPCUDor$OPAMUSEINTERNALSOLVER. Homegrown, organic, locally-sourced solving ๐ฑ-v,--verboseโ Be more verbose. One-vshows all package commands; repeat it to also display commands called internally (e.g.tar,curl,patchetc.). Repeating n times is equivalent to setting$OPAMVERBOSEto"n". Tell me everything ๐ฃ๏ธ--versionโ Shows 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're pointing to. Careful though: since the source directory is copied as it 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โ Answers yes to all opam yes/no questions without prompting. See also--confirm-level. Equivalent to setting$OPAMYESto"true". Yes bestie, obviously ๐
ok that's the first chunk! more of this manual is coming, so don't go anywhere ๐ธ
โจ ENVIRONMENT โจ
okay so bestie, opam is lowkey obsessed with environment variables ๐ it reads a whole bunch of them, and here's the entire list, no skips, no shortcuts, we're doing all of them.
First the rules of the game for the boolean ones: set them to "0", "no", "false" or the empty string to disable them, and "1", "yes" or "true" to enable them. That's it, that's the vibe check ๐ธ
OPAMALLPARENSโ surrounds all filters with parenthesis ๐OPAMASSUMEDEPEXTSโ see option--assume-depexts.OPAMAUTOANSWERโ internal use only ๐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-effortoption is set, and is expected to maximise theopam-queryproperty in the solution.OPAMBUILDDOCโ Removed in 2.1. gone, girl, gone ๐OPAMBUILDTESTโ Removed in 2.1. also gone.OPAMCLIโ see option--cli.OPAMCOLORโ when set toalwaysornever, sets a default value for the--coloroption.OPAMCONFIRMLEVELโ see option--confirm-level.OPAMCONFIRMLEVELhas priority overOPAMYESandOPAMNO.OPAMCRITERIAโ specifies user preferences for dependency solving. The default value depends on the solver version, useconfig reportto know the current setting. See also option--criteria.OPAMCUDFFILEโ save the cudf graph tofile-actions-explicit.dot.OPAMCUDFTRIMโ controls the filtering of unrelated packages during CUDF preprocessing.OPAMCURLโ can be used to select a given'curl'program. SeeOPAMFETCHfor more options.OPAMDEBUGโ see options--debugand--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:2orCLIENT 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. parallel downloads? slay ๐ฅOPAMDROPWORKINGDIRโ overrides packages previously updated with--working-diron 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$EDITORand$VISUAL. it really said "i'm the main character here" ๐OPAMERRLOGLENโ sets the number of log lines printed when a sub-process fails.0to print all.OPAMEXTERNALSOLVERโ see option--solver.OPAMFAKEโ see option--fake.OPAMFETCHโ specifies how to download files: eitherwget,curlor 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 asOPAMUPGRADECRITERIA, 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--lockedand--lock-suffixoptions.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--noand--confirm-level.OPAMNOis ignored if eitherOPAMCONFIRMLEVELorOPAMYESis set.OPAMNOAGGREGATEโ withopam admin check, don't aggregate packages.OPAMNOASPCUDโ Deprecated. ๐ต she's retired, leave her be.OPAMNOAUTOUPGRADEโ disables automatic internal upgrade of repositories in an earlier format to the current one, on'update'or'init'.OPAMNOCHECKSUMSโ enables option--no-checksumswhen 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 tofalseto 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-checksumswhen available (e.g. foropam install).OPAMRETRIESโ sets the number of tries before failing downloads. keep trying bestie, we believe in you ๐ซถOPAMREUSEBUILDDIRโ see option--reuse-build-dir.OPAMROOTโ see option--root. This is automatically set byopam 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.
โ ๏ธ okay babe, that one is Unsafe. it's for compatibility testing only. don't be out here living dangerously for no reason ๐
OPAMSOLVERALLOWSUBOPTIMALโ (defaulttrue) 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. Iftrue, opam will continue with a warning, iffalsea timeout is an error. Currently only the builtin-z3 backend handles this degraded case.OPAMSOLVERTIMEOUTโ change the time allowance of the solver. Default is60.0, set to0for 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 from0.0(best solution known to the solver) to1.0(unoptimized solution). Default is0.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. bye bestie ๐ฆOPAMSTATUSLINEโ display a dynamic status line showing what's currently going on on the terminal. (one ofalways,neverorauto)OPAMSTRICTโ fail on inconsistencies (file reading, switch import, etc.).OPAMSWITCHโ see option--switch. Automatically set byopam env --switch=SWITCH --set-switch.OPAMUNLOCKBASEโ see install option--unlock-base.OPAMUPGRADECRITERIAโ specifies user preferences for dependency solving when performing an upgrade. OverridesOPAMCRITERIAin 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 ofalways,neverorauto). By defaultauto, which is determined from the locale).OPAMUTF8MSGSโ use extended UTF8 characters (camels) in opam messages. ImpliesOPAMUTF8. This is set by default on macOS only. ๐ช๐ช camels!! iconic.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, i'm telling you as a friend.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--yesand--confirm-level.OPAMYEShas priority overOPAMNOand is ignored ifOPAMCONFIRMLEVELis set.OPAMVAR_varโ overrides the contents of the variable var when substituting%{var}%strings inopamfiles.OPAMVAR_package_varโ overrides the contents of the variable package:var when substituting%{package:var}%strings inopamfiles.
๐ CLI VERSION ๐
okay so listen up because this one is a vibe and also genuinely important ๐
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 morethan once, where the last instance takes precedence. OPAMCLI is only inspected if --cli is not given.
๐
the way that "environment variable controlling the parsing of syntax is brittle" is such a read. they're basically saying: please use the flag, bestie, the env var is giving fragile energy. and yes, last --cli wins, so don't stack them expecting the first one to matter, she's overruled ๐
๐ EXIT STATUS ๐
okay so before we get into the numbers, hear me out, there's ONE exception and she's first: the exec command is built different. She returns 127 if the command was not found or couldn't be executed, and otherwise she returns the command's own exit value. everyone else? they follow the list. periodt.
0โ Success bestie!! ๐ Or true for boolean queries. slay.1โ False. She shows up when a boolean return value is expected, like when you're running with--check, or for queries likeopam lint. it's giving "no ๐ " and that's valid.2โ Bad command-line arguments, OR command-line arguments pointing to an invalid context (e.g. a file that doesn't follow the expected format). literally the args said nonsense ๐5โ Not found. You requested something (package, version, repository, etc.) and it couldn't be found. ghosted fr fr ๐ป10โ Aborted. The operation required confirmation, and the confirmation wasn't given. no consent no operation, we love boundaries ๐15โ Could not acquire the locks required for the operation. the door was locked babe ๐20โ There is no solution to the user request. This can be caused by asking to install two incompatible packages, for example. they're not compatible, it's not gonna work, stop trying to make fetch happen ๐ญ30โ Error in package definition, or other metadata files. Heads up: using--strictraises this error more often. โจstricterโจ means more of this.31โ Package script error. Some package operations were unsuccessful. This may be an error in the packages or an incompatibility with your system. Also, this can be a partial error. so like, some of it worked, some of it didn't ๐ซ40โ Sync error. Could not fetch some remotes from the network. And yep, this can also be a partial error. the wifi said not today ๐ง๏ธ50โ Configuration error. Opam or system configuration doesn't allow the operation, and it needs fixing. config said no ๐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 math girlie is not mathing ๐งฎ๐99โ Internal error. Something went wrong, and it's likely due to a bug in opam itself. not your fault bestie, she's just having a moment ๐ญ130โ User interrupt.SIGINTwas received, generally because the user pressed Ctrl+C. that was you. you did that. ๐
and then there's this second little squad, which is the general convention situation, lowkey:
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 ๐
the lore is deep and she's online: see https://opam.ocaml.org/doc. go read, it's giving academic baddie โจ
๐ AUTHORS ๐
the icons the legends the literal main characters who built this. show some respect, say thank you ๐
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>
๐ SEE ALSO ๐
opam(1)โ yeah go read the main one, she's the blueprint ๐
๐ BUGS ๐
found something cursed? Check bug reports at https://github.com/ocaml/opam/issues. do NOT suffer in silence, that's not the vibe, the girls are on GitHub handling it ๐ซถ
and that's the whole page bestie!! ๐
no cap, you now know opam why better than most people know their own passwords. this was OPAM-WHY(1) from the Opam 2.6.1 era, so if you're reading this in the future and something's different, that's a future-you problem, not mine ๐ธ go forth, be the main character of your own switch, and remember: your packages can't explain themselves unless you ask nicely. obsessed with you. bye!! โจ๐ฆ๐
๐ฆ where this page comes from
- arch rolling: opam 2.6.1-1 ยท LGPL-2.1-only
- fedora 44: opam 2.6.1-1.fc44 ยท LGPL-2.1-only WITH OCaml-LGPL-linking-exception
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms