OPAM-REPOSITORY(1)
π OPAM-REPOSITORY π <small>(from the Opam Manual, section 1)</small>
πΈ NAME πΈ
opam-repository β bestie's official way to manage opam repositories π
β¨ SYNOPSIS β¨
opam repository [--kind=KIND] [--rank=RANK] [--short] [OPTION]β¦ [COMMAND] [ARG]β¦
π¦ DESCRIPTION π¦
Okay so listen. This command is the one for managing package repositories, no cap. Repos get registered through the subcommands add, remove and set-url, and then they get refreshed from their URLs using opam update.
Here's the vibe: repository names are global across literally all your switches (main character energy β they belong to everyone β¨), but each switch has its own selection of repositories that it actually pulls package definitions from. So like, the repo is famous, but whether your switch is subscribed to it is totally a per-switch situation π
The main commands β add, remove, set-repos β act only on the current switch, unless you say otherwise using the options explained down in SCOPE SPECIFICATION OPTIONS. Periodt.
And if you run this with no subcommand at all, or with the subcommand list, it lists your selected repositories. Add --all and it'll show you every configured repository instead π
π COMMANDS π
Without any argument, it just defaults to list. That's it, that's the default π«Ά
add NAME [ADDRESS] [QUORUM] [FINGERPRINTS]Adds the repository at address ADDRESS under NAME to the list of configured repositories β but only if it isn't already registered β and then sets this repository for use in the current switch (or whatever scope you specified).
ADDRESS is required if the repository name isn't already registered. And if the name is registered but you give a different address than the registered one, that's an error, bestie, no workarounds.
The quorum is a positive integer that determines the validation threshold for signed repositories, and the fingerprints are the trust anchors for said validation π
Note: By default, the repository is only added to the current switch. To add a repository to other switches, you need--allor--set-default(see below). If what you actually want is a repository enabled only for installing its switches, you may be looking foropam switch create --repositories=REPOS.
remove NAME...Removes the given repositories from the selected scopes (and heads up, the default scope is the current switch β see--this-switch). Want them fully gone?--all-switches, and the repositories are removed completely π
And here's the little plot twist: if the last repository gets removed in the current switch scope, then the selection of repositories is restored to the default selection (opam list --set-default). So you can't accidentally end up repo-less, girlboss π«Ά
set-repos NAME...Explicitly selects the list of repositories to look up package definitions from, in the specified priority order. This overrides any previous selection and ranks, according to whichever scope you specified. Clean slate, your rules πset-url NAME ADDRESS [QUORUM] [FINGERPRINTS]Updates the URL and trust anchors associated with a given repository name.
β οΈ Real talk though: if you don't specify[QUORUM]and[FINGERPRINTS], any previous settings will be erased. Gone. Poof. So type carefully bestie π
listLists the currently selected repositories in priority order, starting from rank 1. With--all, it lists all configured repositories and the switches where they're active. Very "who's in the group chat and who's lurking" energy πpriority NAME RANKA synonym toadd NAME --rank RANK. Just a lil shortcut, that's all π
π SCOPE SPECIFICATION OPTIONS π
These flags let you choose which selections get changed by add, remove and set-repos. And if you specify no flag from this section at all, the updated selections default to the current switch. You can select multiple scopes at once too, e.g. --this-switch --set-default β stacking them like a good fit π₯
-a,--all-switchesβ Act on the selections of all configured switches.--dont-selectβ Don't update any selections. None. Zero. Just vibes.--on-switches=SWITCHESβ Act on the selections of the given list of switches.--set-defaultβ Act on the default repository selection that is used for newly created switches.--this-switchβ Act on the selections for the current switch (this is the default).
π₯ OPTIONS π₯
-k KIND,--kind=KINDβ Specify the kind of the repository to be used (one ofhttp,local,git,darcsorhg).--rank=RANK(absent=1) β Set the rank of the repository in the list of configured repositories. Package definitions are looked in the repositories in increasing rank order, therefore1is the highest priority. Negative ints can be used to select from the lowest priority,-1being last. And ngl,set-reposcan otherwise be used to explicitly set the repository list at once.-s,--shortβ Output raw lists of names, one per line, skipping any details. No frills, just names πΈ
β¨ COMMON OPTIONS β¨
These options are common to all commands. Yes, all of them. Universal besties π
--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 the$OPAMBESTEFFORTenvironment 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 theOPAMCLIenvironment variable to2.0instead of using this parameter.--color=WHENβ Colorize the output. WHEN must be one ofalways,neverorauto. (Set it toalways, it's cute π)--confirm-level=LEVELβ Confirmation level, LEVEL must be one ofask,no,yesorunsafe-yes. Can be specified more than once. If--yesor--noare also given, the value of the last--confirm-levelis taken into account. This is equivalent to setting$OPAMCONFIRMLEVEL.--criteria=CRITERIAβ Specify user preferences for dependency solving for this run. Overrides$OPAMCRITERIA,$OPAMFIXUPCRITERIAand$OPAMUPGRADECRITERIA. For details on the supported language, and the external solvers available, seehttp://opam.ocaml.org/doc/External_solvers.html. A general guide to using solver preferences can be found athttp://www.dicosmo.org/Articles/usercriteria.pdf.--cudf=FILENAMEβ Debug option: Save the CUDF requests sent to the solver toFILENAME-<n>.cudfwhere<n>is the n-th call to the solver during the opam run.--debugβ Print debug message tostderr. This is equivalent to setting$OPAMDEBUGto"true".--debug-level=LEVELβ Like--debug, but allows specifying the debug level (--debugsets it to 1). 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 format FMT. The value FMT must be one ofauto,pager,grofforplain. Withauto, the format ispagerorplainwhenever theTERMenv var isdumbor undefined.--ignore-pin-dependsβ Ignore extra pins required by packages that get pinned, either manually throughopam pinor throughopam install DIR. This is equivalent to settingIGNOREPINDEPENDS=true.--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. π She's gone, don't look for her.--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 usingopam admin upgrade [--mirror URL]when possible.--no-self-upgradeβ Opam will replace itself with a newer binary found atOPAMROOT/opamif present. This disables this behaviour.-q,--quietβ Disables--verbose. Shhh π€«--root=ROOTβ Use ROOT as the current root path. This is equivalent to setting$OPAMROOTto ROOT.--safe,--readonlyβ Make sure nothing will be automatically updated or rewritten. Useful for calling from completion scripts, for example. Will fail whenever such an operation is needed; also avoids waiting for locks, skips interactive questions and overrides the$OPAMDEBUGvariable. This is equivalent to set environment variable$OPAMSAFE.--solver=CMDβ Specify the CUDF solver to use for resolving package installation problems. This is either a predefined solver (this version of opam supportsbuiltin-mccs+lp(),builtin-mccs+glpk,builtin-dummy-z3-solver,builtin-0install,aspcud,mccs,aspcud-old,packup), or a custom command that should contain the variables%{input}%,%{output}%,%{criteria}%, and optionally%{timeout}%. This is equivalent to setting$OPAMEXTERNALSOLVER.--strictβ Fail whenever an error is found in a package definition or a configuration file. The default is to continue silently if possible.--switch=SWITCHβ Use SWITCH as the current compiler switch. This is equivalent to setting$OPAMSWITCHto SWITCH.--use-internal-solverβ Disable any external solver, and use the built-in one (this requires that opam has been compiled with a built-in solver). This is equivalent to setting$OPAMNOASPCUDor$OPAMUSEINTERNALSOLVER.-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". Say yes bestie π
π ENVIRONMENT π
Okay bestie, grab a snack, because opam reads a lot of environment variables and you're about to meet every single one of them. π
Boolean variables should be set to "0", "no", "false" or the empty string to disable them, and to "1", "yes" or "true" to enable them. That's the whole vibe check. β
OPAMALLPARENSβ wraps every filter in parenthesis. all of them. no filter left behind. π«ΆOPAMASSUMEDEPEXTSβ check out the--assume-depextsoption, that's the tea.OPAMAUTOANSWERβ internal use only, nothing to see here, move along. πOPAMAUTOREMOVEβ see the remove option `--auto-remove'.OPAMBESTEFFORTβ go peek at `--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 theopam-query' property in the solution.OPAMBUILDDOCβ π Removed in 2.1. she's gone.OPAMBUILDTESTβ π also Removed in 2.1.OPAMCLIβ see the `--cli' option.OPAMCOLORβ when set to always or never, sets a default value for the `--color' option.OPAMCONFIRMLEVELβ see--confirm-level. Heads up though:OPAMCONFIRMLEVELhas priority overOPAMYESandOPAMNO. she's the main character here. πOPAMCRITERIAβ specifies user preferences for dependency solving. The default value depends on the solver version, so runconfig report' if you wanna know the current setting. See also option--criteria`.OPAMCUDFFILEβ saves 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--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: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. multitasking queen. β¨OPAMDROPWORKINGDIRβ overrides packages previously updated with--working-diron update. Without this variable set, opam would keep them unchanged unless explicitly named on the command-line.OPAMDRYRUNβ see option `--dry-run'.OPAMEDITORβ sets the editor to use for opam file editing, and it overrides$EDITORand$VISUAL. she does not share the spotlight. π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. parallel girlies rise πββοΈ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 the--locked' and--lock-suffix' options.OPAMLOGSβ logdir sets the log directory, default is a temporary directory in/tmp.OPAMMAKECMDβ set the system make command to use.OPAMMERGEOUTβ merge process outputs, stderr on stdout. two streams, one slay. π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, on'update'or'init'.OPAMNOCHECKSUMSβ enables option--no-checksumswhen available.OPAMNODEPEXTSβ disables system dependencies handling, see option `--no-depexts'.OPAMNOENVNOTICEβ Internal. shhh. π€«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. the name is iconic, no notes. π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. 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.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 the builtin-z3 backend 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. πͺβ¨OPAMVALIDATIONHOOKβ if set, uses the%{hook}%command to validate an opam repository update.OPAMVERBOSEβ see option `--verbose'.OPAMVERBOSEONβ see option--verbose-onOPAMVERSIONLAGPOWERβ do not use. π« (genuinely, 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.OPAMYEShas priority overOPAMNOand is ignored ifOPAMCONFIRMLEVEL` is 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 π
Bestie, listen. 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. And not just scripts β blog posts or other documentation can benefit too, because it prevents information from becoming stale. future-proof your faves, periodt. π
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 OPAMCLIspecifies a valid version other than 2.0, and also if--cli=2.0' is specified. so like, it will side-eye you. π
The command-line version is selected by using the --cli' option or the OPAMCLIenvironment 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, she said what she said. π
β¨ EXIT STATUS β¨
okay bestie, hear me out, because this part is lowkey the most useful bit of the whole page π every command tells you a little story through its exit code, and once you know the lore you can basically read opam's mind.
π¨ one big exception first, don't skip it: theexeccommand does NOT play by the rules below. It returns127if the command wasn't found or couldn't be executed, and otherwise it returns the command's own exit value. so if you're pipingopam execsomewhere, yeah, that's a different beast entirely, no cap.
now, the icon list, the main character codes π
0β Success! or "true" for boolean queries. the happy ending we all deserve π1β False. it comes back when a boolean return value is expected, like when you're running with--check, or for queries likeopam lint. it's not an error fr, it's just... a no. π2β Bad command-line arguments, or arguments pointing to an invalid context (for example, a file that doesn't follow the expected format). basically you fed it something cursed.5β Not found. you asked for something (a package, a version, a repository, etc.) and it simply couldn't be found. it's giving ghosted π10β Aborted. the operation needed confirmation and you didn't give it. no consent, no commit β15β Could not acquire the locks required for the operation. someone else is holding the vibe hostage.20β There is no solution to the user request. this can happen if you ask to install two incompatible packages, for example. the math said no π30β Error in package definition, or in other metadata files. heads up: using--strictmakes this error show up wayyyyy more often. you asked for strict, bestie, and strict said bet.31β Package script error. some package operations were unsuccessful. this may be an error in the packages, or an incompatibility with your system. note that this can be a partial error β so not everything fell apart, just... some of it. π«40β Sync error. it couldn't fetch some remotes from the network. also possibly a partial error. the network said "not today" π50β Configuration error. the opam or system configuration doesn't allow the operation, and it needs fixing. you gotta go fix the settings, bestie, there's no shortcut.60β Solver failure. the solver failed to return a sound answer. this can be due to a broken external solver, or an error in solver configuration. the solver is not okay and honestly same π99β Internal error. something went wrong, and it's likely due to a bug in opam itself. not your fault for once, report it β¨130β User interrupt.SIGINTwas received, which is generally because the user pressed Ctrl+C. (it me, I did that π)
and then there's this second little family of codes, same energy, different chart:
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? the docs live at https://opam.ocaml.org/doc β go be nosy, it's encouraged π
π AUTHORS π
look at this absolute squad, actual legends, every single one of them hand-typed into the credits:
- 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>
the way that I'm obsessed with every name here π«Ά
π¦ SEE ALSO π¦
opam(1)β yes, the mothership. go read it next, iykyk.
π BUGS π
found something cursed? spill it. check bug reports at https://github.com/ocaml/opam/issues β the maintainers wanna know, fr fr, and it helps literally everyone π
and that's the whole page, bestie, you made it to the end π this was Opam 2.6.1, answering to the name OPAM-REPOSITORY(1), and you now know it better than 99% of people who type opam every day. slay π
β¨
π¦ where this page comes from
- arch rolling: opam 2.6.1-1 Β· LGPL-2.1-only
- fedora 44: opam 2.6.1-1.fc44 Β· LGPL-2.1-only WITH OCaml-LGPL-linking-exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms