OPAM-ADMIN-FILTER(1)

πŸ’– OPAM ADMIN-FILTER(1) πŸ’–

okay bestie, welcome to the Opam admin Manual β€” this is the glow-up guide for opam admin filter, and no cap, it's a whole vibe. let's get into it 🫢


✨ NAME ✨

opam admin-filter β€” filters a repository to only keep selected packages


🌸 SYNOPSIS 🌸

opam admin filter [--dry-run] [--environment=VAR=VALUE[,VAR=VALUE]]
[--remove] [OPTION]… [PATTERNS]…

πŸ’… DESCRIPTION πŸ’…

so basically, this command removes all package definitions that don't match the search criteria from a repository. and the criteria? specified similarly to opam admin list, queen. if it doesn't match, it's getting evicted. periodt. ✨


πŸ‘‘ ORDER-SENSIBLE SELECTORS πŸ‘‘

these ones are order-sensible, meaning the order you give them in actually matters. iykyk.

  • -a, --available β€” only list packages that are available according to the defined environment. heads up: without --environment, this will include any packages for which availability is not resolvable at this point.
  • -A, --all β€” include literally everything, even uninstalled or unavailable packages. main character energy, no filter πŸ’€
  • --installable β€” only list packages that are installable according to the defined environment. it's giving expensive because this calls the solver and may be more costly. also, a package depending on an unavailable one may be available, but it is never installable. the math is mathing πŸ“
  • --latests-only β€” only list the latest version of each package. no throwbacks, we only keep the newest, slay.

πŸ¦‹ ARGUMENTS πŸ¦‹

  • PATTERNS β€” package patterns with globs. matching against NAME or NAME.VERSION. cute, right?

🌈 OPTIONS 🌈

  • --dry-run β€” list the removal commands without actually performing them. window shopping, bestie πŸ›οΈ
  • --environment=VAR=VALUE[,VAR=VALUE] β€” use the given opam environment, in the form of a list of comma-separated var=value bindings, when resolving variables. this gets used e.g. when computing available packages: if undefined, availability of packages will be assumed as soon as it can not be resolved purely from globally defined variables. note: unless overridden, variables like root or opam-version may be taken from the current opam installation. and what's defined in ~/.opam/config is always ignored β€” no exceptions, sorry not sorry.
  • --remove β€” invert the behaviour and remove the matching packages, keeping the ones that don't match. plot twist ✨

πŸŽ€ PACKAGE SELECTION OPTIONS πŸŽ€

  • --coinstallable-with=PACKAGES β€” only list packages that are compatible with all of PACKAGES. everyone has to get along, no drama allowed 🫢
  • --conflicts-with=PACKAGES β€” list packages that have declared conflicts with at least one of the given list. this includes conflicts defined from the packages in the list, from the other package, or by a common conflict-class: field. messy, but documented πŸ’€
  • --depends-on=PACKAGES β€” only list packages that depend on one of the (comma-separated) PACKAGES.
  • --depopts β€” include optional dependencies in dependency requests. the "eh, maybe" ones πŸ’…
  • --dev β€” include development packages in dependencies.
  • --field-match=FIELD:PATTERN β€” filter packages with a match for PATTERN on the given FIELD. so specific, love that.
  • --has-flag=FLAG β€” only include packages which have the given flag set. package flags are one of: light-uninstall verbose plugin compiler conf. collect them all, bestie πŸŽ€
  • --has-tag=TAG β€” only includes packages which have the given tag set.
  • --nobuild β€” exclude build dependencies (they are included by default). byeee πŸ‘‹
  • --or β€” instead of selecting packages that match all the criteria, select packages that match any of them. either/or, we're flexible like that.
  • --post β€” include dependencies tagged as post.
  • --recursive β€” with --depends-on and --required-by, display all transitive dependencies rather than just direct dependencies. go deep, fr fr 🌊
  • --required-by=PACKAGES β€” only list the dependencies of (comma-separated) PACKAGES.
  • --resolve=PACKAGES β€” restrict to a solution to install (comma-separated) PACKAGES, i.e. a consistent set of packages including those. this is subtly different from --required-by --recursive, which is more predictable and can't fail, but lists all dependencies independently without ensuring consistency. without --installed, the answer is self-contained and independent of the current installation. with --installed, it's computed from the set of currently installed packages. --no-switch further makes the solution independent from the currently pinned packages, architecture, and compiler version. heads up: the combination with --depopts is not supported πŸ’€
  • -t, --with-test, --test β€” include test-only dependencies.
  • --with-dev-setup β€” include developer only dependencies.
  • --with-doc, --doc β€” include doc-only dependencies. the lore must be preserved πŸ“š

πŸ’œ COMMON OPTIONS πŸ’œ

these options are common to all commands. so they show up everywhere, like that one friend who's always in the group pic 😭

  • --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.
  • --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. aesthetic matters 🌈
  • --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. reading is fundamental ✨
  • --cudf=FILENAME β€” debug option: save the CUDF requests sent to the solver to FILENAME-<n>.cudf where <n> is the n-th call to the solver during the opam run.
  • --debug β€” print debug message to stderr. this is equivalent to setting $OPAMDEBUG to "true".
  • --debug-level=LEVEL β€” like --debug, but allows specifying the debug level (--debug sets it to 1). equivalent to setting $OPAMDEBUG to a positive integer.
  • --git-version β€” print the git version of opam, if set (i.e. you are using a development version), and exit.
  • --help[=FMT] (default=auto) β€” show this help in format FMT. the value FMT must be one of auto, pager, groff or plain. with auto, the format is pager or plain whenever the TERM env var is dumb or undefined.
  • --ignore-pin-depends β€” ignore extra pins required by packages that get pinned, either manually through opam pin or through opam install DIR. this is equivalent to setting IGNOREPINDEPENDS=true.
  • --json=FILENAME β€” save the results of the opam run in a computer-readable file. if the filename contains the character %, it will be replaced by an index that doesn't overwrite an existing file. similar to setting the $OPAMJSON variable.
  • --no β€” answer no to all opam yes/no questions without prompting. see also --confirm-level. this is equivalent to setting $OPAMNO to "true".
  • --no-aspcud β€” removed in 2.1. rip, gone but not forgotten πŸ’€
  • --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.
  • -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. no leniency mode, periodt.
  • --switch=SWITCH β€” use SWITCH as the current compiler switch. this is equivalent to setting $OPAMSWITCH to SWITCH.
  • --use-internal-solver β€” disable any external solver, and use the built-in one (this requires that opam has been compiled with a built-in solver). this is equivalent to setting $OPAMNOASPCUD or $OPAMUSEINTERNALSOLVER.
  • -v, --verbose β€” be more verbose. one -v shows all package commands, repeat to also display commands called internally (e.g. tar, curl, patch etc.) repeating n times is equivalent to setting $OPAMVERBOSE to "n". the more the merrier πŸ—£οΈ
  • --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.
  • -y, --yes β€” answer yes to all opam yes/no questions without prompting. see also --confirm-level. this is equivalent to setting $OPAMYES to "true".

✨ ENVIRONMENT ✨

okay so opam</pam>...

sorry, opam is lowkey obsessed with environment variables, and bestie, there are a LOT of them. Here's the full roster, no skips, no shortcuts. πŸ’–

First, the vibe check on 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 rule. ✨


  • OPAMALLPARENS β€” surround all filters with parenthesis. πŸŽ€
  • OPAMASSUMEDEPEXTS β€” see option --assume-depexts.
  • OPAMAUTOANSWER β€” internal use only, bestie, do not touch. πŸ™ˆ
  • OPAMAUTOREMOVE β€” see remove option --auto-remove.
  • OPAMBESTEFFORT β€” see option --best-effort.
  • OPAMBESTEFFORTPREFIXCRITERIA β€” sets the string that must be prepended to the criteria when the --best-effort option is set, and it's expected to maximise the opam-query property in the solution.
  • OPAMBUILDDOC β€” Removed in 2.1. πŸ’€
  • OPAMBUILDTEST β€” Removed in 2.1. πŸ’€
  • OPAMCLI β€” see option --cli.
  • OPAMCOLOR β€” when it's set to always or never, it sets a default value for the --color option.
  • OPAMCONFIRMLEVEL β€” see option --confirm-level. Heads up though: 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 find out 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, this limits debug messages to the space-separated list of sections. Sections can optionally have a specific debug level (for example, CLIENT:2 or CLIENT CUDF:2), but otherwise use --debug-level.
  • OPAMDIGDEPTH β€” defines how aggressive the lookup for conflicts during CUDF preprocessing is.
  • OPAMDOWNLOADJOBS β€” sets the maximum number of simultaneous downloads.
  • OPAMDROPWORKINGDIR β€” overrides packages previously updated with --working-dir on update. Without this variable set, opam would keep them unchanged unless 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.
  • 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. It overrides the download-command value from the main config file.
  • OPAMFIXUPCRITERIA β€” same as OPAMUPGRADECRITERIA, but specific to fixup and reinstall.
  • OPAMIGNOREAVAILABLE β€” see install option --ignore-available-on.
  • OPAMIGNORECONSTRAINTS β€” see install option --ignore-constraints-on.
  • OPAMIGNOREPINDEPENDS β€” see option --ignore-pin-depends.
  • OPAMINPLACEBUILD β€” see option --inplace-build.
  • OPAMJOBS β€” sets the maximum number of parallel workers to run.
  • OPAMJSON β€” log json output to the given file (use 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 the --locked and --lock-suffix options.
  • OPAMLOGS logdir β€” sets the log directory; 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 β€” answer 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. πŸ’€
  • 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 it's 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 it might help you debug 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. πŸ”₯
  • OPAMREQUIRECHECKSUMS β€” enables option --require-checksums when it's 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 one is automatically set by opam env --root=DIR --set-root.
  • OPAMROOTISOK β€” don't complain when running as root. πŸ‘‘
  • OPAMSAFE β€” see option --safe.
  • OPAMSHOW β€” see option --show.
  • OPAMSKIPUPDATE β€” see option --skip-updates.
  • OPAMSKIPVERSIONCHECKS β€” bypasses some version checks. Unsafe, for compatibility testing only, bestie. πŸ’€
  • OPAMSOLVERALLOWSUBOPTIMAL β€” (default true) allows some solvers to still return a solution when they reach timeout; while the solution remains assured to be consistent, there's 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 it 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. it might pull outdated packages). Typical values range from 0.0 (the 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 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, it uses the %{hook}% command to validate an opam repository update.
  • OPAMVERBOSE β€” see option --verbose.
  • OPAMVERBOSEON β€” see option --verbose-on.
  • OPAMVERSIONLAGPOWER β€” do not use. 🚫
  • 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 πŸ‘‘

Every script and every programmatic invocation of opam should use --cli, bestie, no exceptions, so that they work seamlessly with future versions of the opam client. It's giving considerate. 🫢 And as a bonus, blog posts and other documentation get to benefit too, because it prevents information from becoming stale (iykyk πŸ“‰).

Even though 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 (because opam 2.0 will just ignore it), and use --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. Not me being watched like that. πŸ‘€

The command-line version gets selected by using the --cli option or the OPAMCLI environment variable. --cli may be specified more than once, and in that case the last instance takes precedence. OPAMCLI is only inspected if --cli is not given. Periodt. πŸ’…

✨ EXIT STATUS ✨

okay bestie, here's the thing that breaks the pattern: the exec command is built different. As an exception to everything below, exec returns 127 if the command was not found or couldn't be executed, and otherwise it returns the command's own exit value. no cap, it's just Like That πŸ’…

  • 0 β€” Success! Or true for boolean queries. slay βœ…
  • 1 β€” False. Comes back when a boolean return value is expected, like when you're running with --check, or for queries such as opam lint.
  • 2 β€” Bad command-line arguments 😭 or command-line arguments pointing at an invalid context (think: a file that doesn't follow the expected format).
  • 5 β€” Not found. You asked for something (a package, version, repository, etc.) that just… couldn't be found πŸ«₯
  • 10 β€” Aborted. The operation needed confirmation and you didn't give it πŸ™ˆ
  • 15 β€” Couldn't acquire the locks required for the operation πŸ”’
  • 20 β€” There is no solution to the user request. Classic cause: asking to install two incompatible packages. the math isn't mathing πŸ’€
  • 30 β€” Error in package definition, or other metadata files. Heads up: using --strict raises this error more often.
  • 31 β€” Package script error. Some package operations were unsuccessful. Could be an error in the packages, or an incompatibility with your system. And yes, this can be a partial error.
  • 40 β€” Sync error. Couldn't fetch some remotes from the network 🌐 This can also be a partial error.
  • 50 β€” Configuration error. Opam or system configuration doesn't allow the operation and needs fixing πŸ”§
  • 60 β€” Solver failure. The solver failed to return a sound answer. Maybe it's a broken external solver, maybe it's an error in solver configuration. either way, not the vibe 🧩
  • 99 β€” Internal error. Something went wrong, and it's likely a bug in opam itself. not our fault fr fr πŸ›
  • 130 β€” User interrupt. SIGINT was received, generally because the user pressed Ctrl+C ⌨️
  • 0 β€” on success. (yes bestie, you read that right, 0 again πŸ’–)
  • 123 β€” on indiscriminate errors reported on standard error.
  • 124 β€” on command line parsing errors.
  • 125 β€” on unexpected internal errors (bugs).

πŸ“š FURTHER DOCUMENTATION

See https://opam.ocaml.org/doc. go read it, it's giving educational queen πŸ‘‘


πŸ‘‘ AUTHORS

the icons who made this happen, literal legends:

  • 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

like, obviously. the main character herself πŸ’…


πŸ› BUGS

Found a bug? Check bug reports at https://github.com/ocaml/opam/issues β€” and be nice about it, the maintainers are doing their best 🫢


kay that's a wrap bestie! πŸŽ€ this page is from Opam admin 2.6.1, and the OPAM ADMIN-FILTER(1) page itself carries that version and its date down in the footer β€” go forth and filter those packages, you absolute icon βœ¨πŸ¦‹πŸ’–

πŸ“¦ where this page comes from