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.g pkg, pkg.1.0 or pkg>=0.5 ; or files or directory names containing package description, with explicit directory (e.g. ./foo.opam or .)

🌲 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 the PACKAGES. it's giving "we only care where this ends up".
  • --roots-from β€” Display only the trees which roots from one of the PACKAGES (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 as post. 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 *.opam files. Cf. --subpath also. she goes deep. she does not stop at the top level. πŸ”
  • --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. 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 of aspcud or mccs should). This is equivalent to setting $OPAMBESTEFFORT environment 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 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. and yes bestie, we always pick colour, we're not monsters. 🌈
  • --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.
  • --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". the receipts, everything on the record. πŸ’€
  • --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. 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 of auto, pager, groff or plain. With auto, the format is pager or plain whenever the TERM env var is dumb or undefined.
  • --ignore-pin-depends β€” Ignore extra pins required by packages that get pinned, either manually through opam pin or through opam install DIR. This is equivalent to setting IGNOREPINDEPENDS=true. 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 $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". 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 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. 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 $OPAMROOT to ROOT.
  • --safe, --readonly β€” Make sure nothing will be automatically updated or rewritten. Useful for calling from completion scripts, for example. Will fail whenever such an operation is needed ; also avoids waiting for locks, skips interactive questions and overrides the $OPAMDEBUG variable. This is equivalent to set environment variable $OPAMSAFE.
  • --solver=CMD β€” Specify the CUDF solver to use for resolving package installation problems. This is either a predefined solver (this version of opam supports builtin-mccs+lp(), builtin-mccs+glpk, builtin-dummy-z3-solver, builtin-0install, aspcud, mccs, aspcud-old, packup), or a custom command that should contain the variables %{input}%, %{output}%, %{criteria}%, and optionally %{timeout}%. This is equivalent to setting $OPAMEXTERNALSOLVER.
  • --strict β€” Fail whenever an error is found in a package definition or a configuration file. The default is to continue silently if possible. strict queen behaviour. no notes. 😀
  • --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. we do it ourselves here. πŸ’ͺ
  • -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". 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 $OPAMYES to "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-depexts option 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-effort option is set, and is expected to maximise the opam-query property 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 --color option.
  • OPAMCONFIRMLEVEL β€” see option --confirm-level. And listen: OPAMCONFIRMLEVEL has priority over OPAMYES and OPAMNO.
  • OPAMCRITERIA β€” specifies user preferences for dependency solving. The default value depends on the solver version, so run 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. she's nosy fr πŸ•΅οΈ
  • 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, and it overrides $EDITOR and $VISUAL.
  • OPAMERRLOGLEN β€” sets the number of log lines printed when a sub-process fails. Set it to 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 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. 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 --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. Heads up: OPAMNO is ignored if either OPAMCONFIRMLEVEL or OPAMYES is set.
  • OPAMNOAGGREGATE β€” with opam admin check, don't aggregate packages.
  • OPAMNOASPCUD β€” Deprecated.
  • OPAMNOAUTOUPGRADE β€” disables automatic internal upgrade of repositories in an earlier format to the current one, on 'update' or 'init'.
  • OPAMNOCHECKSUMS β€” enables 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. 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 β€” (default true) allows some solvers to still return a solution when they reach timeout; while the solution remains assured to be consistent, there is no guarantee in this case that it fits the expected optimisation criteria. If true, opam willcontinue with a warning, if false a timeout is an error. Currently only the builtin-z3 backend handles this degraded case.
  • OPAMSOLVERTIMEOUT β€” change the time allowance of the solver. Default is 60.0, set to 0 for unlimited. Note that all solvers may not support this option.
  • OPAMSOLVERTOLERANCE β€” changes the tolerance towards the solver choosing an unoptimized solution (i.e. might pull outdated packages). Typical values range from 0.0 (best solution known to the solver) to 1.0 (unoptimized solution). Default is 0.0. This option is useful in case the solver can't find a solution in a reasonable time (see $OPAMSOLVERTIMEOUT). Note that all solvers may not support this option.
  • OPAMSTATS β€” Removed in 2.4.
  • OPAMSTATUSLINE β€” display a dynamic status line showing what's currently going on on the terminal. (one of one of always, never or auto)
  • OPAMSTRICT β€” fail on inconsistencies (file reading, switch import, etc.).
  • OPAMSWITCH β€” see 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.
  • 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. 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 --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 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 OPAMCLI to select 2.0 support (as opam 2.0 will just ignore it)
  • and use --cli=2.1 for 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, or true for boolean queries. we ate πŸ’…
  • 1 β€” False. Returned when a boolean return value is expected, e.g. when running with --check, or for queries like opam 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 --strict raises 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. SIGINT was 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:

https://opam.ocaml.org/doc


πŸ‘‘ 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