OPAM-OPTION(1)
π OPAM-OPTION π
okay bestie, welcome to opam-option β the part of the Opam Manual where we talk about Global and switch configuration options settings. yes. it's the settings page. the vibe is: you're tweaking your config, and this command is your girl π«Ά
β¨ SYNOPSIS β¨
opam option [--global] [OPTION]β¦ [FIELD[(=|+=|-=)[VALUE]]]
πΈ DESCRIPTION πΈ
so like, here's the tea β β what opam option does depends entirely on what you hand it:
- no argument at all? it lists every single configurable field for you. window shopping. π
- just a field name,
FIELD? it shows you what that field's content is. simple. iconic. - anything else? it sets or updates that field in the global/switch configuration file. now you're doing something.
and for global configuration specifically: FIELD gets reset to its default initial value β like, the value it would have right after a fresh init. if you wanna peek at what that looks like, run opam init show-default-opamrc. no cap. π
π§ ARGUMENTS π§
FIELD[(=|+=|-=)[VALUE]]β the whole drama happens here, bestie:- if you give only
FIELD, it displays its associated value. that's it. that's the whole job. π - if
VALUEis absent,FIELD's value gets reverted. like an undo button but for config. - otherwise, its value is updated, and you get to pick the flavour of update:
=β overwrite it. (out with the old, periodt.)+=β append an element. (adding to the collection β¨)-=β remove an element. (blocked and deleted π)
- if you give only
π OPTIONS π
--globalβ Act on global configuration.
π COMMON OPTIONS π
these ones are common to all commands, so you'll be seeing their faces everywhere. learn them, love them. π
--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.--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`.π (yes the backtick situation is a little cursed, we don't talk about it)--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 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. π (she's gone, bestie. 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.--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 π¦
okok so opam reads a BUNCH of environment variables, and bestie, there are so many of them. Every single one is listed below, no skips. π
First tho, the rules for the boolean ones: set them to "0", "no", "false" or the empty string to turn it off, and "1", "yes" or "true" to turn it on. That's the whole vibe check. β¨
OPAMALLPARENSβ surround all filters with parenthesis.OPAMASSUMEDEPEXTSβ see the--assume-depextsoption.OPAMAUTOANSWERβ internal use only. not for you bestie πOPAMAUTOREMOVEβ see the remove option--auto-remove.OPAMBESTEFFORTβ see the--best-effortoption.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 the--clioption.OPAMCOLORβ when set toalwaysornever, it sets a default value for the--coloroption.OPAMCONFIRMLEVELβ see the--confirm-leveloption.OPAMCONFIRMLEVELhas priority overOPAMYESandOPAMNO. πOPAMCRITERIAβ specifies user preferences for dependency solving. The default value depends on the solver version β useconfig reportto know the current setting. See also the--criteriaoption.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 givencurlprogram. SeeOPAMFETCHfor more options.OPAMDEBUGβ see the--debugand--debug-leveloptions.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.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 the--dry-runoption.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.0prints all of them.OPAMEXTERNALSOLVERβ see the--solveroption.OPAMFAKEβ see the--fakeoption.OPAMFETCHβ specifies how to download files: eitherwget,curl, or 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 the install option--ignore-available-on.OPAMIGNORECONSTRAINTSβ see the install option--ignore-constraints-on.OPAMIGNOREPINDEPENDSβ see the--ignore-pin-dependsoption.OPAMINPLACEBUILDβ see the--inplace-buildoption.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 the 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--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 the--noand--confirm-leveloptions.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 the option--no-checksumswhen available.OPAMNODEPEXTSβ disables system dependencies handling, see the option--no-depexts.OPAMNOENVNOTICEβ Internal.OPAMNOSELFUPGRADEβ see the 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 debugging 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 the option--require-checksumswhen available (e.g. foropam install).OPAMRETRIESβ sets the number of tries before failing downloads.OPAMREUSEBUILDDIRβ see the option--reuse-build-dir.OPAMROOTβ see the option--root. This is automatically set byopam env --root=DIR --set-root.OPAMROOTISOKβ don't complain when running as root.OPAMSAFEβ see the option--safe.OPAMSHOWβ see the option--show.OPAMSKIPUPDATEβ see the 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 willcontinue 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 of one ofalways,neverorauto)OPAMSTRICTβ fail on inconsistencies (file reading, switch import, etc.).OPAMSWITCHβ see the option--switch. Automatically set byopam env --switch=SWITCH --set-switch.OPAMUNLOCKBASEβ see the install option--unlock-base.OPAMUPGRADECRITERIAβ specifies user preferences for dependency solving when performing an upgrade. OverridesOPAMCRITERIAin upgrades if both are set. See also the--criteriaoption.OPAMUSEINTERNALSOLVERβ see the option--use-internal-solver.OPAMUSEOPENSSLβ Removed in 2.2. πOPAMUTF8β use UTF8 characters in output (one of 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 the option--verbose.OPAMVERBOSEONβ see the option--verbose-on.OPAMVERSIONLAGPOWERβ do not use. πOPAMWITHDEVSETUPβ see the install option--with-dev-setup.OPAMWITHDOCβ see the install option--with-doc.OPAMWITHTESTβ see the install option--with-test.OPAMWORKINGDIRβ see the option--working-dir.OPAMYESβ see the 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 important and you're gonna wanna hear me out. π
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 it's not just for scripts β blog posts or other documentation can benefit too, because it prevents information from becoming stale.
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 β because an environment variable controlling the parsing of syntax is brittle, fr fr. To this end, opam displays a warning if OPAMCLI specifies a valid version other than 2.0, and also if --cli=2.0 is specified.
The command-line version is selected by using the --cli option or the OPAMCLI environment variable. --cli may be specified morethan once, where the last instance takes precedence. OPAMCLI is only inspected if --cli is not given. π
πͺ EXIT STATUS (a.k.a. "what did that number MEAN")
Okay bestie, plot twist incoming: the exec command is the β¨rebelβ¨ that plays by its own rules. It does not follow the list below. exec returns 127 if the command wasn't found or couldn't be executed at all, and otherwise it returns the command's own exit value. That's it, that's the lore. π
For literally everything else, here's the codebook:
0β Success, ortruefor boolean queries. The good ending. π1β False. This pops up when a boolean return value is what's expected, e.g. when you run with--check, or for queries likeopam lint. Lowkey a "no" rather than a "something broke".2β Bad command-line arguments, or command-line arguments pointing at an invalid context, like a file that doesn't follow the expected format. Bestie, check your flags. π5β Not found. You asked for something β a package, a version, a repository, etc. β that literally could not be found. It's giving missing.10β Aborted. The operation needed you to confirm something and you didn't give the confirmation. Consent matters, even in package managers. π«Ά15β Could not acquire the locks required for the operation. Somebody else is holding the door. π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 other metadata files. And heads up: using--strictraises this error more often. π31β Package script error. Some package operations were unsuccessful. This may be an error in the packages or an incompatibility with your system. And note: this can be a partial error β so part of it might have worked, which, rude.40β Sync error. Could not fetch some remotes from the network. This can be a partial error too. The internet is being a flop again. π50β Configuration error. Opam or your system configuration doesn't allow the operation and needs fixing. Not a bug, a chore.60β Solver failure. The solver failed to return a sound answer. Could be a broken external solver, or an error in the solver configuration. The solver just handed in blank paper. π99β Internal error. Something went wrong, likely due to a bug in opam itself. Not your fault, babes. Report it.130β User interrupt.SIGINTwas received, generally because the user pressed Ctrl+C. Yeah, that was you. No shame.
And then, for the commands that specifically document their own bit of the spectrum:
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
Go read more, it's cute over there: https://opam.ocaml.org/doc.
π AUTHORS (the icons who built this)
- 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>
Absolute legends, every single one. β¨
π SEE ALSO
opam(1)β go read the main one too, it's the moment.
π BUGS
Check bug reports at https://github.com/ocaml/opam/issues. If you found one, tell them! They wanna know! π«Ά
And that's a wrap, bestie!! π This was the OPAM-OPTION(1) manual page from Opam 2.6.1 β go forth, run your commands, and may all your exit statuses be 0. ππ¦β¨
π¦ 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