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 againstNAMEorNAME.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-separatedvar=valuebindings, 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 likerootoropam-versionmay be taken from the current opam installation. and what's defined in~/.opam/configis 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 ofPACKAGES. 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 commonconflict-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 forPATTERNon the givenFIELD. so specific, love that.--has-flag=FLAGβ only include packages which have the given flag set. package flags are one of:light-uninstallverboseplugincompilerconf. 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 aspost.--recursiveβ with--depends-onand--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-switchfurther makes the solution independent from the currently pinned packages, architecture, and compiler version. heads up: the combination with--depoptsis 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 ofaspcudormccsshould). this is equivalent to setting$OPAMBESTEFFORTenvironment variable.--cli=MAJOR.MINOR(absent=2.6) β use the command-line interface syntax and semantics ofMAJOR.MINOR. intended for any persistent use of opam (scripts, blog posts, etc.), any version of opam in the sameMAJORseries will behave as for the specifiedMINORrelease. 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.WHENmust be one ofalways,neverorauto. aesthetic matters π--confirm-level=LEVELβ confirmation level,LEVELmust 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. reading is fundamental β¨--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 to stderr. this is equivalent to setting$OPAMDEBUGto"true".--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.--help[=FMT](default=auto) β show this help in formatFMT. the valueFMTmust 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.--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".--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 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.-q,--quietβ disables--verbose. shhh π€«--root=ROOTβ useROOTas the current root path. this is equivalent to setting$OPAMROOTtoROOT.--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. no leniency mode, periodt.--switch=SWITCHβ useSWITCHas the current compiler switch. this is equivalent to setting$OPAMSWITCHtoSWITCH.--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.-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". 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$OPAMYESto"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-effortoption is set, and it's expected to maximise theopam-queryproperty in the solution.OPAMBUILDDOCβ Removed in 2.1. πOPAMBUILDTESTβ Removed in 2.1. πOPAMCLIβ see option--cli.OPAMCOLORβ when it's set toalwaysornever, it sets a default value for the--coloroption.OPAMCONFIRMLEVELβ see option--confirm-level. Heads up though:OPAMCONFIRMLEVELhas priority overOPAMYESandOPAMNO. πOPAMCRITERIAβ specifies user preferences for dependency solving. The default value depends on the solver version, so runconfig reportto 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. SeeOPAMFETCHfor more options.OPAMDEBUGβ see options--debugand--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: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.OPAMDROPWORKINGDIRβ overrides packages previously updated with--working-diron 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$EDITORand$VISUAL.OPAMERRLOGLENβ sets the number of log lines printed when a sub-process fails.0to print all of them. πOPAMEXTERNALSOLVERβ see option--solver.OPAMFAKEβ see option--fake.OPAMFETCHβ specifies how to download files: eitherwget,curlor a custom command where the variables%{url}%,%{out}%,%{retry}%,%{compress}%and%{checksum}%will be replaced. It overrides thedownload-commandvalue 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 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--lockedand--lock-suffixoptions.OPAMLOGSlogdir β 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--noand--confirm-level.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, onupdateorinit.OPAMNOCHECKSUMSβ enables option--no-checksumswhen 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 tofalseto 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-checksumswhen it's 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 one 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, bestie. πOPAMSOLVERALLOWSUBOPTIMALβ (defaulttrue) 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. Iftrue, opam will continue with a warning; iffalse, a 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 it to0for 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 from0.0(the 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 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 of one ofalways,neverorauto). By default it'sauto, which is determined from the locale).OPAMUTF8MSGSβ use extended UTF8 characters (camels πͺ) in opam messages. It impliesOPAMUTF8. 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--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 π
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! Ortruefor 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 asopam 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--strictraises 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.SIGINTwas received, generally because the user pressed Ctrl+C β¨οΈ0β on success. (yes bestie, you read that right,0again π)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
opam admin(1)
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
- 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