OPAM-TREE(1)
π³ OPAM-TREE β the Opam Manual glow-up edition π³
okay bestie, sit DOWN, because we're about to look at the actual family tree of your opam packages and it's giving ancestry.com but make it β¨Unicode artβ¨. yes this is opam-tree(1), and no it is not boring, I promise π«Ά
β¨ SYNOPSIS β¨
opam tree [--recursive] [--subpath=PATH] [OPTION]β¦ [PACKAGES]β¦
like. that's it. that's the whole vibe. π
π¦ DESCRIPTION π¦
so this command draws the forest of currently installed packages for you, as Unicode/ASCII art. a lil forest. of dependencies. iconic honestly. π²
No arguments? It draws the dependency forest of the packages that have no dependants β like, the ones nobody else needs, the true main characters. π
With PACKAGES arguments? It draws the forest of those specific packages instead. And when you name packages that aren't installed, it will try to simulate installing them before drawing the forest, just to show you what the tree would look like. so thoughtful of it ngl.
When the --rev-deps option is used, it draws the reverse-dependency forest instead. No arguments β it draws the forest of packages with no dependencies. With PACKAGES arguments β it draws the forest of the specified packages. β οΈ but heads up bestie: non-installed packages are ignored when this option is used. they simply don't get an invite to this party.
When a package shows up twice or more in the forest β the second and later appearances get marked as a duplicate, annotated with the [*] symbol. and any sub-trees rooted from those duplicates get truncated to avoid redundancy. she's efficient like that, respect. π―
Go look at the TREE FILTERING OPTIONS and PACKAGE SELECTION OPTIONS sections for all the ways to pick which packages get displayed, and OUTPUT FORMAT OPTIONS for customising how the output looks. iykyk. π
If what you actually want is a flat list of packages which may not be installed, go see opam list instead. different vibe entirely.
π ARGUMENTS π
PACKAGESβ List of package names, with an optional version or constraint, e.gpkg,pkg.1.0orpkg>=0.5; or files or directory names containing package description, with explicit directory (e.g../foo.opamor.)
π² TREE BUILDING OPTIONS π²
--depsβ Draw a dependency forest, starting from the packages not required by any other packages (this is the default). this is the queen bee behaviour, the default setting, the standard. π--rev-depsβ Draw a reverse-dependency forest, starting from the packages which have no dependencies. flipped. reversed. upside down. we love her. π
π§ TREE FILTERING OPTIONS π§
β οΈ These options only take effect when PACKAGES are present. like, they literally do nothing otherwise. zero notes, empty. π
--leads-toβ Display only the branches which leads to one of thePACKAGES. it's giving "we only care where this ends up".--roots-fromβ Display only the trees which roots from one of thePACKAGES(this is the default). the classic, the standard, the moment. π±
πΈ PACKAGE SELECTION OPTIONS πΈ
--devβ Include development packages in dependencies. let the devs in, they've earned it. π οΈ--no-switchβ Ignore active switch and simulate installing packages from an empty switch to draw the forest. clean slate energy, no baggage, fresh start, main character reboot. β¨--postβ Include dependencies tagged aspost. the "after party" dependencies. π-t,--with-test,--testβ Include test-only dependencies. yes bestie, we're testing in prod, come along. π§ͺ--with-dev-setupβ Include developer only dependencies. the setup crew, the behind-the-scenes girlies. π¬--with-doc,--docβ Include doc-only dependencies. for the readers, the scholars, the girlies who read the docs (rare, legendary). π
π OUTPUT FORMAT OPTIONS π
--no-constraintβ Do not display the version constraints e.g.(>= 1.0.0). minimalism, clean lines, less is more, periodt. βοΈ
β OPTIONS β
--recursiveβ Allow recursive lookups of*.opamfiles. Cf.--subpathalso. she goes deep. she does not stop at the top level. π--subpath=PATHβ*.opamfiles 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--recursiveto have a recursive lookup on the subpath. basically: "not the whole folder, just this one little corner of it, thanks." ποΈ
π COMMON OPTIONS π
These options are common to all commands. so they're not special to opam-tree, but they're still here, they still count, and they're still eating. π½οΈ
--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 ofaspcudormccsshould). This is equivalent to setting$OPAMBESTEFFORTenvironment variable. she tries her best and that's what matters. π«Ά--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 theOPAMCLIenvironment variable to2.0instead of using this parameter.--color=WHENβ Colorize the output. WHEN must be one ofalways,neverorauto. and yes bestie, we always pick colour, we're not monsters. π--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.--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. π--cudf=FILENAMEβ Debug option: Save the CUDF requests sent to the solver toFILENAME-<n>.cudfwhere<n>is the n-th call to the solver during the opam run. π--debugβ Print debug message tostderr. This is equivalent to setting$OPAMDEBUGto"true". the receipts, everything on the record. π--debug-level=LEVELβ Like--debug, but allows specifying the debug level (--debugsets it to1). Equivalent to setting$OPAMDEBUGto a positive integer.--git-versionβ Print the git version of opam, if set (i.e. you are using a development version), and exit. then she's gone. immediate exit. no small talk. πͺ--help[=FMT](default=auto) β Show this help in format FMT. The value FMT must be one ofauto,pager,grofforplain. Withauto, the format ispagerorplainwhenever theTERMenv var isdumbor undefined.--ignore-pin-dependsβ Ignore extra pins required by packages that get pinned, either manually throughopam pinor throughopam install DIR. This is equivalent to settingIGNOREPINDEPENDS=true. we're pretending we didn't see that pin, bestie. π--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$OPAMJSONvariable. π€--noβ Answer no to all opam yes/no questions without prompting. See also--confirm-level. This is equivalent to setting$OPAMNOto"true". she said NO. bald. no explanation. π«--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 arepofile 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 usingopam admin upgrade [--mirror URL]when possible.--no-self-upgradeβ Opam will replace itself with a newer binary found atOPAMROOT/opamif present. This disables this behaviour. no glow-up for you today. π-q,--quietβ Disables--verbose. shhh. π€«--root=ROOTβ Use ROOT as the current root path. This is equivalent to setting$OPAMROOTto 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$OPAMDEBUGvariable. 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 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}%. 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. strict queen behaviour. no notes. π€--switch=SWITCHβ Use SWITCH as the current compiler switch. This is equivalent to setting$OPAMSWITCHto 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$OPAMNOASPCUDor$OPAMUSEINTERNALSOLVER. we do it ourselves here. πͺ-v,--verboseβ Be more verbose. One-vshows all package commands, repeat to also display commands called internally (e.g.tar,curl,patchetc.) Repeating n times is equivalent to setting$OPAMVERBOSEto"n". give me the FULL lore. π’--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. β οΈ uncommitted changes, bestie. the build might not survive it.-y,--yesβ Answer yes to all opam yes/no questions without prompting. See also--confirm-level. This is equivalent to setting$OPAMYESto"true". yes yes yes, she's agreeing to everything, chaotic but valid. β
π ENVIRONMENT π
ok so opam is β¨environmentally awareβ¨ bestie, and these are all the little knobs it reads from your env. Important note: for boolean variables, set them to "0", "no", "false" or just the empty string to turn them OFF, and "1", "yes" or "true" to turn them ON π
OPAMALLPARENSβ wraps literally every filter in parenthesis, no exceptions, slay.OPAMASSUMEDEPEXTSβ peep the--assume-depextsoption for the tea.OPAMAUTOANSWERβ internal use only, not for us girlies π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-effortoption is set, and is expected to maximise theopam-queryproperty in the solution.OPAMBUILDDOCβ bestie she's Removed in 2.1 πOPAMBUILDTESTβ also Removed in 2.1 πOPAMCLIβ see option--cli.OPAMCOLORβ when set to always or never, sets a default value for the--coloroption.OPAMCONFIRMLEVELβ see option--confirm-level. And listen:OPAMCONFIRMLEVELhas priority overOPAMYESandOPAMNO.OPAMCRITERIAβ specifies user preferences for dependency solving. The default value depends on the solver version, so runconfig 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. she's nosy fr π΅οΈOPAMDOWNLOADJOBSβ sets the maximum number of simultaneous downloads.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, and it overrides$EDITORand$VISUAL.OPAMERRLOGLENβ sets the number of log lines printed when a sub-process fails. Set it to0to print all of them π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. multitasking queen π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/tmpOPAMMAKECMDβ 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. Heads up:OPAMNOis ignored if eitherOPAMCONFIRMLEVELorOPAMYESis set.OPAMNOAGGREGATEβ withopam 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-checksumswhen available.OPAMNODEPEXTSβ disables system dependencies handling, see option--no-depexts.OPAMNOENVNOTICEβ Internal.OPAMNOSELFUPGRADEβ see option--no-self-upgradeOPAMPINKINDAUTOβ 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 astar.gzfiles (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.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. living dangerously, we love to see it πOPAMSAFEβ see option--safe.OPAMSHOWβ see option--show.OPAMSKIPUPDATEβ see option--skip-updates.OPAMSKIPVERSIONCHECKSβ bypasses some version checks. Unsafe, for compatibility testing only. bestie do not do this casually π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 willcontinue with a warning, iffalsea timeout is an error. Currently only thebuiltin-z3backend 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.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 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 of one of always, never or auto). 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.OPAMVALIDATIONHOOKβ if set, uses the%{hook}%command to validate an opam repository update.OPAMVERBOSEβ see option--verbose.OPAMVERBOSEONβ see option--verbose-onOPAMVERSIONLAGPOWERβ do not use. girlie said 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--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 π¦
ok so here's the vibe: every script and programmatic invocation of opam should use --cli, no cap, because that's how you make sure your stuff keeps working seamlessly with future versions of the opam client. And it's not just for scripts β blog posts and other documentation can benefit too, because it prevents information from becoming stale. slay π
So even though opam only supports roots (~/.opam/) for the current version, it does provide backwards compatibility for its command-line interface. iconic behaviour honestly.
Here's the catch though bestie: CLI version support was only added in opam 2.1, so:
- use
OPAMCLIto select 2.0 support (as opam 2.0 will just ignore it) - and use
--cli=2.1for 2.1 (or later) versions
because apparently 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. And plot twist: --cli may be specified morethan once, where the last instance takes precedence π₯ OPAMCLI is only inspected if --cli is not given.
π EXIT STATUS π
okay bestie, so here's the deal with exit codes β but first, the drama: as an exception to everything below, the exec command is special. It returns 127 if the command was not found or couldn't be executed, and otherwise it gives you the command's own exit value. main character behaviour, honestly.
Here's the whole vibe check π
0β Success, ortruefor boolean queries. we ate π1β False. Returned when a boolean return value is expected, e.g. when running with--check, or for queries likeopam lint. it's giving "no β€οΈ"2β Bad command-line arguments, or command-line arguments pointing to an invalid context (e.g. file not following the expected format). bestie what did you type π5β Not found. You requested something (package, version, repository, etc.) that couldn't be found. it's not here, babes π«₯10β Aborted. The operation required confirmation, which wasn't given. you said no, so it said no back π15β Could not acquire the locks required for the operation. locked out π20β There is no solution to the user request. This can be caused by asking to install two incompatible packages, for example. they're fighting, they cannot both come π30β Error in package definition, or other metadata files. Using--strictraises this error more often. lowkey strict mode is that friend who notices everything π€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. the wifi said not today πΆ50β Configuration error. Opam or system configuration doesn't allow operation, and needs fixing. fix ur settings babe βοΈ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 your fault, that one's on opam π₯130β User interrupt.SIGINTwas received, generally due to the user pressing Ctrl+C. you mashed the emergency brake, iconic π
and then there's this little extra squad of codes β¨:
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 goes deeper, bestie β check it out here:
π AUTHORS π
these are the absolute legends who built this thing, put some respect on their names π«Ά:
- 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 πΈ
go read its sibling, they're a package deal fr fr:
π BUGS π
found a lil gremlin in the code? π¦ check bug reports right here, bestie:
https://github.com/ocaml/opam/issues
aaaand that's a wrap on the whole page, bestie!! π this was Opam 2.6.1 of the OPAM-TREE(1) manual, and the way it served?? unmatched. no cap. now go build that tree and slay πβ¨πΊπ
π¦ 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