OPAM-ADMIN(1)
π OPAM ADMIN(1) π
okay so welcome to page one of the Opam admin Manual, bestie β this is the section-1 glow-up for repo admins, and it's lowkey iconic. π
π NAME π
opam admin β the literal toolbox for repository administrators. That's the whole job description. π
π SYNOPSIS π
opam admin [COMMAND] β¦
β¨ DESCRIPTION β¨
So this command does a whole bunch of actions on repositories in the opam format. Fr fr, it's built different β but here's the tea: it expects to be run from the root of a repository, i.e. a directory that contains a repo file and a subdirectory packages/ holding package definition within subdirectories. ποΈ
Also a compilers/ subdirectory (that's opam repository format version < 2) will also be used by the upgrade-format subcommand. Don't ask why, it just will. π
π¦ COMMANDS π¦
Pick your fighter, bestie β every single one is listed below, no skips, no cap. π«Ά
π add-constraint
opam admin add-constraint [--force] [--packages=PACKAGES] [OPTION]β¦ PACKAGE
Adds version constraints on all dependencies towards a given package. π
π add-hashes
opam admin add-hashes [--packages=PACKAGES] [--replace] [OPTION]β¦ HASH_ALGOβ¦
Add archive hashes to an opam repository. Slay. β¨
π cache
opam admin cache [OPTION]β¦ [DIR]
Fills a local cache of package archives. It's giving hoarding but make it useful. π
π check
opam admin check [OPTION]β¦
Runs some consistency checks on a repository. Vibe check, basically. π
π compare-versions
opam admin compare-versions [OPTION]β¦ V0 V1
Compare two package versions. Who wore it better. π
π filter
opam admin filter [--dry-run] [--environment=VAR=VALUE[,VAR=VALUE]] [--remove] [OPTION]β¦ [PATTERNS]β¦
Filters a repository to only keep selected packages. Unfollow everyone else. π«
π help
opam admin help [--man-format=FMT] [OPTION]β¦ [TOPIC]
Display help about opam admin and opam admin subcommands. Yes queen, ask away. πββοΈ
π index
opam admin index [--full-urls-txt] [--minimal-urls-txt] [--no-urls-txt] [OPTION]β¦
Generate an inclusive index file for serving over HTTP. Main character energy. π
π lint
opam admin lint [OPTION]β¦ [INT]β¦
Runs opam lint and reports on a whole repository. Constructive criticism only, obviously. π§
π list
opam admin list [--environment=VAR=VALUE[,VAR=VALUE]] [OPTION]β¦ [PATTERNS]β¦
Lists packages from a repository. A whole roster. π
π migrate-extrafiles
opam admin migrate-extrafiles [--hash=HASH_ALGO] [--packages=PACKAGES] [OPTION]β¦ DIR URL
Move extra-files to extra-source. Moving day, bestie. π¦
π update-extrafiles
opam admin update-extrafiles [--hash=HASH_ALGO] [--packages=PACKAGES] [OPTION]β¦
Add extra-files to an opam repository. β¨
π upgrade
opam admin upgrade [--clear-cache] [--mirror=URL] [OPTION]β¦
Upgrades repository from earlier opam versions. Growth era. π±
π« COMMAND ALIASES π«
Sometimes one name just isn't enough, iykyk. π
πΈ make
opam admin make [--full-urls-txt] [--minimal-urls-txt] [--no-urls-txt] [OPTION]β¦
An alias for index. Same energy, different name. π«Ά
π₯ COMMON OPTIONS π₯
These options are common to all commands β so learn them once and you're set for life. No cap. π―
--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. Yes, we are doing aesthetics. π--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, 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 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. π (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. π€--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". π£οΈ--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 bestie, so opam is deeply into environment variables. like, it has opinions. it reads the ones listed here, and you can use them to tweak basically anything without typing a single flag π
first tho, the rules of the game for boolean variables: set them to "0", "no", "false" or the empty string to turn them off, and "1", "yes" or "true" to turn them on. that's it, that's the whole language π₯
and now, the lineup π
OPAMALLPARENSβ surrounds all filters with parenthesis. that's the whole job, she's simple and she delivers β¨OPAMASSUMEDEPEXTSβ see option--assume-depexts.OPAMAUTOANSWERβ internal use only. not for you bestie, look away πOPAMAUTOREMOVEβ see remove option--auto-remove.OPAMBESTEFFORTβ see option--best-effort.OPAMBESTEFFORTPREFIXCRITERIAβ sets the string that must be prepended to the criteria when the--best-effortoption is set, and is expected to maximise theopam-queryproperty in the solution.OPAMBUILDDOCβ Removed in 2.1. gone, deceased, no longer with us πOPAMBUILDTESTβ Removed in 2.1. same fate πOPAMCLIβ see option--cli.OPAMCOLORβ when set toalwaysornever, sets a default value for the--coloroption.OPAMCONFIRMLEVELβ see option--confirm-level. and hear me out: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 on purpose π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, overrides$EDITORand$VISUAL. she said my editor, not yours πOPAMERRLOGLENβ sets the number of log lines printed when a sub-process fails.0to print all.OPAMEXTERNALSOLVERβ see option--solver.OPAMFAKEβ see option--fake.OPAMFETCHβ specifies how to download files: eitherwget,curlor a custom command where variables%{url}%,%{out}%,%{retry}%,%{compress}%and%{checksum}%will be replaced. overrides the'download-command'value from the main config file.OPAMFIXUPCRITERIAβ same asOPAMUPGRADECRITERIA, but specific to fixup and reinstall.OPAMIGNOREAVAILABLEβ see install option--ignore-available-on.OPAMIGNORECONSTRAINTSβ see install option--ignore-constraints-on.OPAMIGNOREPINDEPENDSβ see option--ignore-pin-depends.OPAMINPLACEBUILDβ see option--inplace-build.OPAMJOBSβ sets the maximum number of parallel workers to run.OPAMJSONβ log json output to the given file (use character%to index the files).OPAMKEEPBUILDDIRβ see install option--keep-build-dir.OPAMKEEPLOGSβ tells opam to not remove some temporary command logs and some backups. this skips some finalisers and may also help to get more reliable backtraces.OPAMLOCKEDβ combination of--lockedand--lock-suffixoptions.OPAMLOGSβ logdir sets log directory, default is a temporary directory in/tmp.OPAMMAKECMDβ set the system make command to use.OPAMMERGEOUTβ merge process outputs, stderr on stdout.OPAMNOβ answer no to any question asked, see options--noand--confirm-level.OPAMNOis ignored if eitherOPAMCONFIRMLEVELorOPAMYESis set.OPAMNOAGGREGATEβ withopam admin check, don't aggregate packages.OPAMNOASPCUDβ Deprecated. let her rest πOPAMNOAUTOUPGRADEβ disables automatic internal upgrade of repositories in an earlier format to the current one, on'update'or'init'.OPAMNOCHECKSUMSβ enables option--no-checksumswhen available.OPAMNODEPEXTSβ disables system dependencies handling, see option--no-depexts.OPAMNOENVNOTICEβ Internal.OPAMNOSELFUPGRADEβ see option--no-self-upgrade.OPAMPINKINDAUTOβ sets whether version control systems should be detected when pinning to a local path. enabled by default since 1.3.0.OPAMPRECISETRACKINGβ fine grain tracking of directories.OPAMPREPROβ set this 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.OPAMSAFEβ see option--safe.OPAMSHOWβ see option--show.OPAMSKIPUPDATEβ see option--skip-updates.OPAMSKIPVERSIONCHECKSβ bypasses some version checks. Unsafe, for compatibility testing only. do NOT make this your personality π«OPAMSOLVERALLOWSUBOPTIMALβ (defaulttrue) allows some solvers to still return a solution when they reach timeout; while the solution remains assured to be consistent, there is no guarantee in this case that it fits the expected optimisation criteria. iftrue, opam will continue with a warning, iffalsea timeout is an error. currently only 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 ofalways,neverorauto)OPAMSTRICTβ fail on inconsistencies (file reading, switch import, etc.).OPAMSWITCHβ see option--switch. automatically set byopam env --switch=SWITCH --set-switch.OPAMUNLOCKBASEβ see install option--unlock-base.OPAMUPGRADECRITERIAβ specifies user preferences for dependency solving when performing an upgrade. overridesOPAMCRITERIAin upgrades if both are set. see also option--criteria.OPAMUSEINTERNALSOLVERβ see option--use-internal-solver.OPAMUSEOPENSSLβ Removed in 2.2. πOPAMUTF8β use UTF8 characters in output (one ofalways,neverorauto). by defaultauto, which is determined from the locale).OPAMUTF8MSGSβ use extended UTF8 characters (camels) in opam messages. impliesOPAMUTF8. this is set by default on macOS only. πͺ iconic behavior honestlyOPAMVALIDATIONHOOKβ 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. that's it. that's the description. do NOT use it bestie π«OPAMWITHDEVSETUPβ see install option--with-dev-setup.OPAMWITHDOCβ see install option--with-doc.OPAMWITHTESTβ see install option--with-test.OPAMWORKINGDIRβ see option--working-dir.OPAMYESβ see options--yesand--confirm-level.OPAMYEShas priority overOPAMNOand is ignored ifOPAMCONFIRMLEVELis set.OPAMVAR_varβ overrides the contents of the variable var when substituting%{var}%strings inopamfiles.OPAMVAR_package_varβ overrides the contents of the variable package:var when substituting%{package:var}%strings inopamfiles.
π¦ CLI VERSION π¦
okay so this one is the important one for anyone writing scripts, and i need you to lock in π
all scripts and programmatic invocations of opam should use --cli in order to ensure that they work seamlessly with future versions of the opam client. additionally, blog posts or other documentation can benefit, as it prevents information from becoming stale. like, future-proof your blog babe, it costs nothing β¨
although opam only supports roots (~/.opam/) for the current version, it does provide backwards compatibility for its command-line interface.
since CLI version support was only added in opam 2.1, use OPAMCLI to select 2.0 support (as opam 2.0 will just ignore it), and --cli=2.1 for 2.1 (or later) versions, since an environment variable controlling the parsing of syntax is brittle. to this end, opam displays a warning if OPAMCLI specifies a valid version other than 2.0, and also if --cli=2.0 is specified. π noted.
the command-line version is selected by using the --cli option or the OPAMCLI environment variable. --cli may be specified more than once, where the last instance takes precedence. OPAMCLI is only inspected if --cli is not given. last one wins, periodt π
π₯ EXIT STATUS π₯
Okay bestie, this is the part where opam admin tells you how it's feeling by handing you a number. Every exit code is a whole mood, and reading them correctly is the glow-up. π
Heads up though, there's one big exception before we even start: theexeccommand does not play by these rules. It returns127if the command wasn't found or couldn't be executed, and otherwise it returns the command's own exit value. Iconic behaviour, honestly. β¨
Now, the codes:
0β Success, ortruefor boolean queries. Living your best life. π1β False. This is what you get when a boolean return value is expected, like when you're running with--check, or for queries likeopam lint.2β Bad command-line arguments, or command-line arguments that point to an invalid context (think: a file that doesn't follow the expected format). Not me typing the flag wrong again π5β Not found. You asked for something β a package, a version, a repository, etc. β and it genuinely could not be found. π¦10β Aborted. The operation needed confirmation and you didn't give it. It's giving "asked and then ghosted."15β Could not acquire the locks required for the operation. Somebody else has the aux files, bestie, wait your turn. π20β There is no solution to the user request. This can happen when you ask to install two incompatible packages, for example. Math said no. π30β Error in package definition, or in other metadata files. Using--strictraises this error more often. Petty, but fair.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 β not everything fell over, just some of it.40β Sync error. Could not fetch some remotes from the network. This can be a partial error too. The internet said "not today." π50β Configuration error. Opam or your system configuration doesn't allow the operation, and it needs fixing. β¨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.99β Internal error. Something went wrong, likely due to a bug in opam itself. Not your fault, queen. π«Ά130β User interrupt.SIGINTwas received, generally because the user pressed Ctrl+C. Yes, that was you. It was always you. π
And then there's this little second set of codes that shows up right at the end, chillin' on their own:
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 π
Want more lore? Go read the docs at https://opam.ocaml.org/doc. That's the homework, and it's actually good reading. β¨
π AUTHORS π
These are the absolute legends who built this thing. Show some respect, they literally wrote the tool you're arguing with right now. π
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>
π BUGS π
Found something cursed? Check the bug reports at https://github.com/ocaml/opam/issues. Filing it is self-care, fr fr. π¦
And that's a wrap on the whole page, bestie!! π The footer down there says this is Opam admin 2.6.1 and that you're reading OPAM ADMIN(1) β no date on it, so don't come for me. Go forth, run your commands, read your exit codes, and remember: you're the main character of this terminal. periodt. π
β¨πΈ
π¦ 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